Skip to main content

Scatter

Trait Scatter 

Source
pub unsafe trait Scatter<'data> {
    // Required methods
    fn remaining(&self) -> usize;
    unsafe fn advance<const MAX: usize>(
        &mut self,
        cap: NonZero<usize>,
        left: NonZero<usize>,
    ) -> Chunk<'data, MAX>;

    // Provided methods
    fn seek(self, offset: usize) -> Option<Self>
       where Self: Sized { ... }
    fn take_bytes(&mut self, limit: usize) -> Take<'_, 'data, Self> ⓘ
       where Self: Sized { ... }
}
Expand description

Exact-progress traversal over one immutable scattered source.

§Safety

Progress, cap, remaining length, and 'data must all be exact.

Required Methods§

Source

fn remaining(&self) -> usize

Source

unsafe fn advance<const MAX: usize>( &mut self, cap: NonZero<usize>, left: NonZero<usize>, ) -> Chunk<'data, MAX>

Advances from the exact non-empty state represented by left.

§Safety

left == self.remaining(), cap <= left, cap <= MAX; output advances 1..=cap bytes.

Provided Methods§

Source

fn seek(self, offset: usize) -> Option<Self>
where Self: Sized,

Advances to an admitted byte offset in this exact cursor.

Source

fn take_bytes(&mut self, limit: usize) -> Take<'_, 'data, Self> ⓘ
where Self: Sized,

Borrows at most the requested number of remaining bytes.

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<'data, C: Scatter<'data> + ?Sized> Scatter<'data> for &mut C

Source§

fn remaining(&self) -> usize

Source§

unsafe fn advance<const MAX: usize>( &mut self, cap: NonZero<usize>, left: NonZero<usize>, ) -> Chunk<'data, MAX>

Source§

impl<'data> Scatter<'data> for &'data [u8]

Source§

fn remaining(&self) -> usize

Source§

unsafe fn advance<const MAX: usize>( &mut self, cap: NonZero<usize>, _left: NonZero<usize>, ) -> Chunk<'data, MAX>

Implementors§

Source§

impl<'a, T: Segment> Scatter<'a> for Cursor<'a, T>

Source§

impl<'a, T: Segment> Scatter<'a> for Iter<'a, T>