Trait BodyChunk

Source
pub trait BodyChunk: Sized {
    // Required methods
    fn split_at(self, idx: usize) -> (Self, Self);
    fn as_slice(&self) -> &[u8] ;

    // Provided methods
    fn len(&self) -> usize { ... }
    fn is_empty(&self) -> bool { ... }
    fn into_vec(self) -> Vec<u8>  { ... }
}
Expand description

The operations required from a body stream’s Item type.

Required Methods§

Source

fn split_at(self, idx: usize) -> (Self, Self)

Split the chunk at idx, returning (self[..idx], self[idx..]).

Source

fn as_slice(&self) -> &[u8]

Get the slice representing the data of this chunk.

Provided Methods§

Source

fn len(&self) -> usize

Equivalent to self.as_slice().len()

Source

fn is_empty(&self) -> bool

Equivalent to self.as_slice().is_empty()

Source

fn into_vec(self) -> Vec<u8>

Equivalent to self.as_slice().to_owned()

Implementors are welcome to override this if they can provide a cheaper conversion.

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 BodyChunk for Vec<u8>

Source§

fn split_at(self, idx: usize) -> (Self, Self)

Source§

fn as_slice(&self) -> &[u8]

Source§

fn into_vec(self) -> Vec<u8>

Source§

impl<'a> BodyChunk for &'a [u8]

Source§

fn split_at(self, idx: usize) -> (Self, Self)

Source§

fn as_slice(&self) -> &[u8]

Implementors§