Skip to main content

Fragment

Trait Fragment 

Source
pub trait Fragment: SplitByteSlice {
    // Required methods
    fn take_front(&mut self, n: usize) -> Option<Self>;
    fn take_back(&mut self, n: usize) -> Option<Self>;
    fn empty() -> Self;
}
Expand description

A single byte slice fragment in a FragmentedByteSlice.

Required Methods§

Source

fn take_front(&mut self, n: usize) -> Option<Self>

Takes n bytes from the front of this fragment.

After a call to take_front(n), the fragment is n bytes shorter.

Returns None if n is larger than the length of this ByteSlice.

Source

fn take_back(&mut self, n: usize) -> Option<Self>

Takes n bytes from the back of this fragment.

After a call to take_back(n), the fragment is n bytes shorter.

Returns None if n is larger than the length of this ByteSlice.

Source

fn empty() -> Self

Constructs a new empty Fragment.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

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

Source§

fn take_front(&mut self, n: usize) -> Option<Self>

Source§

fn take_back(&mut self, n: usize) -> Option<Self>

Source§

fn empty() -> Self

Source§

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

Source§

fn take_front(&mut self, n: usize) -> Option<Self>

Source§

fn take_back(&mut self, n: usize) -> Option<Self>

Source§

fn empty() -> Self

Implementors§