pub struct Body(/* private fields */);Expand description
A fetch body. Single-use: reading it (buffer or stream) consumes it.
Implementations§
Source§impl Body
impl Body
pub fn empty() -> Self
pub fn from_bytes(bytes: impl Into<Bytes>) -> Self
pub fn from_stream(stream: ByteStream) -> Self
Sourcepub async fn collect(self) -> Result<Bytes, FetchError>
pub async fn collect(self) -> Result<Bytes, FetchError>
Buffer the whole body into Bytes.
§Errors
Returns FetchError::Body if a stream chunk or the network read
fails.
Sourcepub fn into_stream(self) -> ByteStream
pub fn into_stream(self) -> ByteStream
Convert the body into a chunk stream (for a WHATWG Response.body
ReadableStream). An empty body yields an empty stream.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Body
impl !RefUnwindSafe for Body
impl !Sync for Body
impl !UnwindSafe for Body
impl Send for Body
impl Unpin for Body
impl UnsafeUnpin for Body
Blanket Implementations§
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