Skip to content

Commit

Permalink
Implement MessageBody for Markup
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede authored and lambda-fairy committed Jun 16, 2024
1 parent d46ce8c commit adb9742
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion maud/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,35 @@ mod rocket_support {

#[cfg(feature = "actix-web")]
mod actix_support {
use core::{
pin::Pin,
task::{Context, Poll},
};

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;

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> {
type Body = String;

Expand Down

0 comments on commit adb9742

Please sign in to comment.