pub enum Body {
Empty,
Bytes(Vec<u8>),
Stream {
stream: Mutex<RequestBodyStream>,
content_length: Option<usize>,
},
}Expand description
Request body.
Variants§
Empty
Empty body.
Bytes(Vec<u8>)
Bytes body.
Stream
Streaming body, optionally with a known content length.
Implementations§
Source§impl Body
impl Body
Sourcepub fn streaming_with_size<S>(stream: S, content_length: usize) -> Self
pub fn streaming_with_size<S>(stream: S, content_length: usize) -> Self
Create a streaming body with a known content length.
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Get body as bytes, consuming it.
Note: streaming bodies cannot be synchronously collected; this returns
an empty vector for Body::Stream.
Sourcepub fn into_stream(self) -> Option<(RequestBodyStream, Option<usize>)>
pub fn into_stream(self) -> Option<(RequestBodyStream, Option<usize>)>
Take ownership of the inner stream, if this is a streaming body.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Body
impl RefUnwindSafe for Body
impl Send for Body
impl Sync for Body
impl Unpin for Body
impl UnwindSafe 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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).