pub struct Body { /* private fields */ }Expand description
The body of a request or a response: bytes held in memory, a stream, or a stream that can be made again.
A body held in memory can be cloned (Body::try_clone), which is what lets a retry layer send a request again.
So can a body made from a replayable Upload, such as a file, which is opened again for each
attempt. Any other 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. It must be
Send and Sync, except on WebAssembly (MaybeSend, MaybeSync).
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. It must be
Send, except on WebAssembly (MaybeSend).
Sourcepub fn try_clone(&self) -> Option<Self>
pub fn try_clone(&self) -> Option<Self>
A copy of the body: a body held in memory, or a fresh start of one that can be made again (a file
Upload, say); None for a stream that can be read once.
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,
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>
Source§fn inspect_frame<F>(self, f: F) -> InspectFrame<Self, F>
fn inspect_frame<F>(self, f: F) -> InspectFrame<Self, F>
Source§fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
Source§fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
Source§fn boxed_unsync(self) -> UnsyncBoxBody<Self::Data, Self::Error>
fn boxed_unsync(self) -> UnsyncBoxBody<Self::Data, Self::Error>
Source§fn collect(self) -> Collect<Self> ⓘwhere
Self: Sized,
fn collect(self) -> Collect<Self> ⓘwhere
Self: Sized,
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>
Source§fn into_stream(self) -> BodyStream<Self>where
Self: Sized,
fn into_stream(self) -> BodyStream<Self>where
Self: Sized,
BodyStream.Source§fn into_data_stream(self) -> BodyDataStream<Self>where
Self: Sized,
fn into_data_stream(self) -> BodyDataStream<Self>where
Self: Sized,
BodyDataStream.