packet

Trait FragmentedBuffer

Source
pub trait FragmentedBuffer {
    // Required methods
    fn len(&self) -> usize;
    fn with_bytes<R, F>(&self, f: F) -> R
       where F: for<'a, 'b> FnOnce(FragmentedBytes<'a, 'b>) -> R;

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

A buffer that may be fragmented in multiple parts which are discontiguous in memory.

Required Methods§

Source

fn len(&self) -> usize

Gets the total length, in bytes, of this FragmentedBuffer.

Source

fn with_bytes<R, F>(&self, f: F) -> R
where F: for<'a, 'b> FnOnce(FragmentedBytes<'a, 'b>) -> R,

Invokes a callback on a view into this buffer’s contents as FragmentedBytes.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns true if this FragmentedBuffer is empty.

Source

fn to_flattened_vec(&self) -> Vec<u8>

Returns a flattened version of this buffer, copying its contents into a Vec.

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 FragmentedBuffer for Infallible

Source§

fn len(&self) -> usize

Source§

fn with_bytes<R, F>(&self, _f: F) -> R
where F: for<'a, 'b> FnOnce(FragmentedBytes<'a, 'b>) -> R,

Source§

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

Source§

fn len(&self) -> usize

Source§

fn with_bytes<R, F>(&self, f: F) -> R
where F: for<'macro_a, 'macro_b> FnOnce(FragmentedBytes<'macro_a, 'macro_b>) -> R,

Source§

fn to_flattened_vec(&self) -> Vec<u8>

Source§

impl<'a> FragmentedBuffer for &'a mut [u8]

Source§

fn len(&self) -> usize

Source§

fn with_bytes<R, F>(&self, f: F) -> R
where F: for<'macro_a, 'macro_b> FnOnce(FragmentedBytes<'macro_a, 'macro_b>) -> R,

Source§

fn to_flattened_vec(&self) -> Vec<u8>

Implementors§