use super::core::IntoHtml;
use crate::Response;
use crate::headers::ContentType;
use crate::service::web::response::{Headers, IntoResponse};
#[derive(Debug, Clone, Copy)]
pub struct HtmlBuf<T>(pub T);
impl<T: IntoHtml> IntoHtml for HtmlBuf<T> {
#[inline]
fn into_html(self) -> impl IntoHtml {
self.0
}
#[inline]
fn escape_and_write(self, buf: &mut String)
where
Self: Sized,
{
self.0.escape_and_write(buf);
}
#[inline]
fn size_hint(&self) -> usize {
self.0.size_hint()
}
}
impl<T: IntoHtml> IntoResponse for HtmlBuf<T> {
fn into_response(self) -> Response {
let body = self.0.into_string();
(Headers::single(ContentType::html_utf8()), body).into_response()
}
}