#![deny(
missing_debug_implementations,
missing_docs,
unreachable_pub,
rustdoc::broken_intra_doc_links
)]
#![cfg_attr(test, deny(warnings))]
mod collected;
pub mod combinators;
mod either;
mod empty;
mod full;
mod limited;
mod stream;
mod util;
use self::combinators::{BoxBody, MapErr, MapFrame, UnsyncBoxBody};
pub use self::collected::Collected;
pub use self::either::Either;
pub use self::empty::Empty;
pub use self::full::Full;
pub use self::limited::{LengthLimitError, Limited};
pub use self::stream::StreamBody;
pub trait BodyExt: http_body::Body {
fn frame(&mut self) -> combinators::Frame<'_, Self>
where
Self: Unpin,
{
combinators::Frame(self)
}
fn map_frame<F, B>(self, f: F) -> MapFrame<Self, F>
where
Self: Sized,
F: FnMut(http_body::Frame<Self::Data>) -> http_body::Frame<B>,
B: bytes::Buf,
{
MapFrame::new(self, f)
}
fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
where
Self: Sized,
F: FnMut(Self::Error) -> E,
{
MapErr::new(self, f)
}
fn boxed(self) -> BoxBody<Self::Data, Self::Error>
where
Self: Sized + Send + Sync + 'static,
{
BoxBody::new(self)
}
fn boxed_unsync(self) -> UnsyncBoxBody<Self::Data, Self::Error>
where
Self: Sized + Send + 'static,
{
UnsyncBoxBody::new(self)
}
fn collect(self) -> combinators::Collect<Self>
where
Self: Sized,
{
combinators::Collect {
body: self,
collected: Some(crate::Collected::default()),
}
}
}
impl<T: ?Sized> BodyExt for T where T: http_body::Body {}