Implement MessageBody for Markup ()

This commit is contained in:
Rob Ede 2024-06-16 13:27:33 +01:00 committed by GitHub
parent d46ce8c23a
commit ddc9b4cb2a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -302,10 +302,35 @@ mod rocket_support {
#[cfg(feature = "actix-web")] #[cfg(feature = "actix-web")]
mod actix_support { mod actix_support {
use core::{
pin::Pin,
task::{Context, Poll},
};
use crate::PreEscaped; use crate::PreEscaped;
use actix_web_dep::{http::header, HttpRequest, HttpResponse, Responder}; use actix_web_dep::{
body::{BodySize, MessageBody},
http::header,
web::Bytes,
HttpRequest, HttpResponse, Responder,
};
use alloc::string::String; use alloc::string::String;
impl MessageBody for PreEscaped<String> {
type Error = <String as MessageBody>::Error;
fn size(&self) -> BodySize {
self.0.size()
}
fn poll_next(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Option<Result<Bytes, Self::Error>>> {
Pin::new(&mut self.0).poll_next(cx)
}
}
impl Responder for PreEscaped<String> { impl Responder for PreEscaped<String> {
type Body = String; type Body = String;