http1::body::http_body

Trait HttpBody

source
pub trait HttpBody {
    type Err;
    type Data: Into<Vec<u8>>;

    // Required method
    fn read_next(&mut self) -> Result<Option<Self::Data>, Self::Err>;

    // Provided methods
    fn size_hint(&self) -> Option<usize> { ... }
    fn read_all_bytes(&mut self) -> Result<Vec<u8>, Self::Err> { ... }
}
Expand description

Represents an object that can be used to read the request or response body data.

Required Associated Types§

Required Methods§

source

fn read_next(&mut self) -> Result<Option<Self::Data>, Self::Err>

Returns the next chunk of data.

Provided Methods§

source

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

Returns the total size of the data to write.

source

fn read_all_bytes(&mut self) -> Result<Vec<u8>, Self::Err>

Read all the chunks and returns a Vec containing all the bytes.

Implementations on Foreign Types§

source§

impl HttpBody for ()

source§

type Err = Infallible

source§

type Data = Vec<u8>

source§

fn read_next(&mut self) -> Result<Option<Self::Data>, Self::Err>

source§

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

source§

impl HttpBody for String

source§

type Err = Infallible

source§

type Data = Vec<u8>

source§

fn read_next(&mut self) -> Result<Option<Self::Data>, Self::Err>

source§

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

source§

impl HttpBody for Arc<File>

source§

type Err = Error

source§

type Data = Vec<u8>

source§

fn read_next(&mut self) -> Result<Option<Self::Data>, Self::Err>

source§

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

source§

impl HttpBody for Vec<u8>

source§

type Err = Infallible

source§

type Data = Vec<u8>

source§

fn read_next(&mut self) -> Result<Option<Self::Data>, Self::Err>

source§

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

source§

impl HttpBody for File

source§

type Err = Error

source§

type Data = Vec<u8>

source§

fn read_next(&mut self) -> Result<Option<Self::Data>, Self::Err>

source§

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

source§

impl HttpBody for Empty

source§

type Err = Infallible

source§

type Data = Vec<u8>

source§

fn read_next(&mut self) -> Result<Option<Self::Data>, Self::Err>

source§

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

source§

impl<'a> HttpBody for &'a str

source§

type Err = Infallible

source§

type Data = Vec<u8>

source§

fn read_next(&mut self) -> Result<Option<Self::Data>, Self::Err>

source§

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

source§

impl<R> HttpBody for Box<R>
where R: Read,

source§

type Err = Error

source§

type Data = Vec<u8>

source§

fn read_next(&mut self) -> Result<Option<Self::Data>, Self::Err>

source§

impl<R> HttpBody for BufReader<R>
where R: Read,

source§

type Err = Error

source§

type Data = Vec<u8>

source§

fn read_next(&mut self) -> Result<Option<Self::Data>, Self::Err>

source§

impl<R: Read> HttpBody for Take<R>

source§

type Err = Error

source§

type Data = Vec<u8>

source§

fn read_next(&mut self) -> Result<Option<Self::Data>, Self::Err>

source§

impl<T: AsRef<[u8]>> HttpBody for Cursor<T>

source§

type Err = Error

source§

type Data = Vec<u8>

source§

fn read_next(&mut self) -> Result<Option<Self::Data>, Self::Err>

source§

impl<T: Read, U: Read> HttpBody for Chain<T, U>

source§

type Err = Error

source§

type Data = Vec<u8>

source§

fn read_next(&mut self) -> Result<Option<Self::Data>, Self::Err>

Implementors§