Expand description
The body of a response: can be sized or streamed/chunked.
Variants
Sized(T, u64)
A fixed-size body.
Chunked(T, u64)
A streamed/chunked body, akin to Transfer-Encoding: chunked
.
Implementations
sourceimpl<T> Body<T>
impl<T> Body<T>
sourcepub fn as_mut(&mut self) -> Body<&mut T>
pub fn as_mut(&mut self) -> Body<&mut T>
Returns a new Body
with a mutable borrow to self
’s inner type.
sourcepub fn map<U, F>(self, f: F) -> Body<U>where
F: FnOnce(T) -> U,
pub fn map<U, F>(self, f: F) -> Body<U>where
F: FnOnce(T) -> U,
Consumes self
. Passes the inner type as a parameter to f
and
constructs a new body with the size of self
and the return value of
the call to f
.
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes self
and returns the inner body.
sourcepub fn is_chunked(&self) -> bool
pub fn is_chunked(&self) -> bool
Returns true
if self
is a Body::Chunked
.
sourceimpl<T> Body<T>where
T: Read,
impl<T> Body<T>where
T: Read,
sourcepub fn into_bytes(self) -> Option<Vec<u8, Global>>
pub fn into_bytes(self) -> Option<Vec<u8, Global>>
Attempts to read self
into a Vec
and returns it. If reading fails,
returns None
.
sourcepub fn into_string(self) -> Option<String>
pub fn into_string(self) -> Option<String>
Attempts to read self
into a String
and returns it. If reading or
conversion fails, returns None
.
Trait Implementations
sourceimpl<T> PartialEq<Body<T>> for Body<T>where
T: PartialEq<T>,
impl<T> PartialEq<Body<T>> for Body<T>where
T: PartialEq<T>,
impl<T> StructuralPartialEq for Body<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Body<T>where
T: RefUnwindSafe,
impl<T> Send for Body<T>where
T: Send,
impl<T> Sync for Body<T>where
T: Sync,
impl<T> Unpin for Body<T>where
T: Unpin,
impl<T> UnwindSafe for Body<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> IntoCollection<T> for T
impl<T> IntoCollection<T> for T
fn into_collection<A>(self) -> SmallVec<A>where
A: Array<Item = T>,
fn into_collection<A>(self) -> SmallVec<A>where
A: Array<Item = T>,
Converts
self
into a collection.