diff --git a/src/types/body.rs b/src/types/body.rs index d2da102..a7481c3 100644 --- a/src/types/body.rs +++ b/src/types/body.rs @@ -2,6 +2,8 @@ use tokio::io::AsyncRead; #[cfg(feature="serve_dir")] use tokio::fs::File; +use std::borrow::Borrow; + use crate::types::Document; pub enum Body { @@ -9,9 +11,9 @@ pub enum Body { Reader(Box), } -impl From for Body { - fn from(document: Document) -> Self { - Self::from(document.to_string()) +impl> From for Body { + fn from(document: D) -> Self { + Self::from(document.borrow().to_string()) } } diff --git a/src/types/response.rs b/src/types/response.rs index 991d511..ce1b5b6 100644 --- a/src/types/response.rs +++ b/src/types/response.rs @@ -1,4 +1,5 @@ use std::convert::TryInto; +use std::borrow::Borrow; use anyhow::*; use uriparse::URIReference; @@ -19,7 +20,7 @@ impl Response { } } - pub fn document(document: Document) -> Self { + pub fn document(document: impl Borrow) -> Self { Self::success_with_body(&GEMINI_MIME, document) }