Trait BodyExt
pub trait BodyExt: Body
An extension trait for http_body::Body adding various combinators and adapters
Provided Methods
fn frame(&mut self) -> Frame<'_, Self> where Self: Unpin,Returns a future that resolves to the next
Frame, if any.fn map_frame<F, B>(self, f: F) -> MapFrame<Self, F> where Self: Sized, F: FnMut(Frame<Self::Data>) -> Frame<B>, B: Buf,Maps this body's frame to a different kind.
fn inspect_frame<F>(self, f: F) -> InspectFrame<Self, F> where Self: Sized, F: FnMut(&Frame<Self::Data>),A body that calls a function with a reference to each frame before yielding it.
fn map_err<F, E>(self, f: F) -> MapErr<Self, F> where Self: Sized, F: FnMut(Self::Error) -> E,Maps this body's error value to a different value.
fn inspect_err<F>(self, f: F) -> InspectErr<Self, F> where Self: Sized, F: FnMut(&Self::Error),A body that calls a function with a reference to an error before yielding it.
fn boxed(self) -> BoxBody<Self::Data, Self::Error> where Self: Sized + Send + Sync + 'static,Turn this body into a boxed trait object.
fn boxed_unsync(self) -> UnsyncBoxBody<Self::Data, Self::Error> where Self: Sized + Send + 'static,Turn this body into a boxed trait object that is !Sync.
fn collect(self) -> Collect<Self> where Self: Sized,Turn this body into
Collectedbody which will collect all the DATA frames and trailers.fn with_trailers<F>(self, trailers: F) -> WithTrailers<Self, F> where Self: Sized, F: Future<Output = Option<Result<HeaderMap, Self::Error>>>,Add trailers to the body.
The trailers will be sent when all previous frames have been sent and the
trailersfuture resolves.Example
use HeaderMap; use ; use Bytes; # asyncfn into_stream(self) -> BodyStream<Self> where Self: Sized,Turn this body into
BodyStream.fn into_data_stream(self) -> BodyDataStream<Self> where Self: Sized,Turn this body into
BodyDataStream.fn fuse(self) -> Fuse<Self> where Self: Sized,Creates a "fused" body.
This [
Body][http_body::Body] yieldsPoll::Ready(None)forever after the underlying body yieldsPoll::Ready(None), or an errorPoll::Ready(Some(Err(_))), once.See [
Fuse<B>][combinators::Fuse] for more information.
Implementors
impl<T> BodyExt for BodyStream<B> where T: Body + ?Sized,impl<T> BodyExt for BoxBody<D, E> where T: Body + ?Sized,impl<T> BodyExt for Collected<B> where T: Body + ?Sized,impl<T> BodyExt for Either<L, R> where T: Body + ?Sized,impl<T> BodyExt for Empty<D> where T: Body + ?Sized,impl<T> BodyExt for Full<D> where T: Body + ?Sized,impl<T> BodyExt for Fuse<B> where T: Body + ?Sized,impl<T> BodyExt for InspectErr<B, F> where T: Body + ?Sized,impl<T> BodyExt for InspectFrame<B, F> where T: Body + ?Sized,impl<T> BodyExt for Limited<B> where T: Body + ?Sized,impl<T> BodyExt for MapErr<B, F> where T: Body + ?Sized,impl<T> BodyExt for MapFrame<B, F> where T: Body + ?Sized,impl<T> BodyExt for StreamBody<S> where T: Body + ?Sized,impl<T> BodyExt for T where T: Body + ?Sized,impl<T> BodyExt for UnsyncBoxBody<D, E> where T: Body + ?Sized,impl<T> BodyExt for WithTrailers<T, F> where T: Body + ?Sized,