pub enum RequestBody {
Empty,
Bytes(Bytes),
Text(String),
Json(Vec<u8>),
Form(String),
Stream {
stream: RequestBodyStream,
content_length: Option<u64>,
},
}Expand description
Public request body model.
Streaming variants are non-cloneable and cannot be replayed implicitly. Redirect/retry paths must fail closed when replay would be required instead of cloning a stream into an empty request body. Cloning of in-memory variants remains cheap.
Variants§
Implementations§
Source§impl RequestBody
impl RequestBody
pub fn empty() -> Self
pub fn is_empty(&self) -> bool
Sourcepub fn is_streaming(&self) -> bool
pub fn is_streaming(&self) -> bool
true when the body is a non-materialized streaming producer.
Sourcepub fn content_length(&self) -> Option<u64>
pub fn content_length(&self) -> Option<u64>
Advertised Content-Length for sized streams (and trivially the
in-memory length for materialized variants).
Sourcepub fn into_bytes(self) -> Result<Bytes>
pub fn into_bytes(self) -> Result<Bytes>
Materialize an in-memory body to Bytes. Streaming bodies fail
closed with a clear error rather than being silently buffered.
Trait Implementations§
Source§impl Clone for RequestBody
impl Clone for RequestBody
Source§impl Debug for RequestBody
impl Debug for RequestBody
Source§impl Default for RequestBody
impl Default for RequestBody
Source§fn default() -> RequestBody
fn default() -> RequestBody
Returns the “default value” for a type. Read more
Source§impl From<&[u8]> for RequestBody
impl From<&[u8]> for RequestBody
Source§impl From<&str> for RequestBody
impl From<&str> for RequestBody
Source§impl From<Bytes> for RequestBody
impl From<Bytes> for RequestBody
Source§impl From<String> for RequestBody
impl From<String> for RequestBody
Auto Trait Implementations§
impl !Freeze for RequestBody
impl !RefUnwindSafe for RequestBody
impl Send for RequestBody
impl !Sync for RequestBody
impl Unpin for RequestBody
impl UnsafeUnpin for RequestBody
impl !UnwindSafe for RequestBody
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