pub struct Body { /* private fields */ }Expand description
The body of a request or a response: bytes held in memory, or a stream.
A body held in memory can be cloned (Body::try_clone), which is what lets a retry layer send a request again.
A stream can be read once.
Implementations§
Source§impl Body
impl Body
Sourcepub fn wrap<B>(body: B) -> Self
pub fn wrap<B>(body: B) -> Self
A body that wraps another http_body::Body, such as the body of a hyper or reqwest response.
Sourcepub fn wrap_stream<S>(stream: S) -> Self
pub fn wrap_stream<S>(stream: S) -> Self
A body that reads the chunks of a stream, such as a file read with tokio_util::io::ReaderStream.
Sourcepub async fn collect_bytes(self) -> Result<Bytes, BoxError>
pub async fn collect_bytes(self) -> Result<Bytes, BoxError>
Reads the whole body into memory.
Trait Implementations§
Source§impl Body for Body
impl Body for Body
Auto Trait Implementations§
impl !Freeze for Body
impl !RefUnwindSafe for Body
impl !UnwindSafe for Body
impl Forget for Body
impl Move for Body
impl Send for Body
impl Sync for Body
impl Unpin for Body
impl UnsafeUnpin for Body
Blanket Implementations§
Source§impl<T> BodyExt for T
impl<T> BodyExt for T
Source§fn frame(&mut self) -> Frame<'_, Self> ⓘwhere
Self: Unpin,
fn frame(&mut self) -> Frame<'_, Self> ⓘwhere
Self: Unpin,
Returns a future that resolves to the next
Frame, if any.Source§fn map_frame<F, B>(self, f: F) -> MapFrame<Self, F>
fn map_frame<F, B>(self, f: F) -> MapFrame<Self, F>
Maps this body’s frame to a different kind.
Source§fn inspect_frame<F>(self, f: F) -> InspectFrame<Self, F>
fn inspect_frame<F>(self, f: F) -> InspectFrame<Self, F>
A body that calls a function with a reference to each frame before yielding it.
Source§fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
Maps this body’s error value to a different value.
Source§fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
A body that calls a function with a reference to an error before yielding it.
Source§fn boxed_unsync(self) -> UnsyncBoxBody<Self::Data, Self::Error>
fn boxed_unsync(self) -> UnsyncBoxBody<Self::Data, Self::Error>
Turn this body into a boxed trait object that is !Sync.
Source§fn collect(self) -> Collect<Self> ⓘwhere
Self: Sized,
fn collect(self) -> Collect<Self> ⓘwhere
Self: Sized,
Turn this body into
Collected body which will collect all the DATA frames
and trailers.Source§fn with_trailers<F>(self, trailers: F) -> WithTrailers<Self, F>
fn with_trailers<F>(self, trailers: F) -> WithTrailers<Self, F>
Add trailers to the body. Read more
Source§fn into_stream(self) -> BodyStream<Self>where
Self: Sized,
fn into_stream(self) -> BodyStream<Self>where
Self: Sized,
Turn this body into
BodyStream.Source§fn into_data_stream(self) -> BodyDataStream<Self>where
Self: Sized,
fn into_data_stream(self) -> BodyDataStream<Self>where
Self: Sized,
Turn this body into
BodyDataStream.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more