pub enum Body<T> {
Sized(T, u64),
Chunked(T, u64),
}
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§
source§impl<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: FnOnce(T) -> U>(self, f: F) -> Body<U>
pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Body<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
.
source§impl<T: Read> Body<T>
impl<T: Read> Body<T>
sourcepub fn into_bytes(self) -> Option<Vec<u8>>
pub fn into_bytes(self) -> Option<Vec<u8>>
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§
impl<T> StructuralPartialEq for Body<T>
Auto Trait Implementations§
impl<T> Freeze for Body<T>where
T: Freeze,
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§
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)