RequestBody

Trait RequestBody 

Source
pub trait RequestBody {
    // Required method
    async fn write<W: Write>(&self, writer: &mut W) -> Result<(), W::Error>;

    // Provided method
    fn len(&self) -> Option<usize> { ... }
}
Expand description

The request body

Required Methods§

Source

async fn write<W: Write>(&self, writer: &mut W) -> Result<(), W::Error>

Write the body to the provided writer

Provided Methods§

Source

fn len(&self) -> Option<usize>

Get the length of the body if known

If the length is known, then it will be written in the Content-Length header, chunked encoding will be used otherwise.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl RequestBody for &[u8]

Source§

fn len(&self) -> Option<usize>

Source§

async fn write<W: Write>(&self, writer: &mut W) -> Result<(), W::Error>

Source§

impl RequestBody for ()

Source§

fn len(&self) -> Option<usize>

Source§

async fn write<W: Write>(&self, _writer: &mut W) -> Result<(), W::Error>

Source§

impl<T> RequestBody for Option<T>
where T: RequestBody,

Source§

fn len(&self) -> Option<usize>

Source§

async fn write<W: Write>(&self, writer: &mut W) -> Result<(), W::Error>

Implementors§