Skip to main content

Spans

Trait Spans 

Source
pub unsafe trait Spans:
    Copy
    + Send
    + Sync
    + 'static {
    const EMPTY: Self;

    // Required methods
    unsafe fn span(self, index: usize) -> (usize, usize);
    unsafe fn advance(self, count: usize) -> (usize, Self);
}
Expand description

Where the values of a Buf are in its storage: the range of octets of each of them, either computed, see PackedSpans, or given by a table, see TableSpans.

§Safety

The ranges must be those the buffer was built with.

Required Associated Constants§

Source

const EMPTY: Self

The spans of no values at all.

Required Methods§

Source

unsafe fn span(self, index: usize) -> (usize, usize)

The offset and the length, in octets, of the value at that index, relative to where the buffer starts in its storage.

§Safety

The buffer these are the spans of must hold a value at that index.

Source

unsafe fn advance(self, count: usize) -> (usize, Self)

How many octets further the buffer starts, and the spans, of the buffer starting that many values further, which is what slicing is made of.

§Safety

The buffer these are the spans of must hold at least that many values.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl Spans for TableSpans

Source§

const EMPTY: Self

Source§

impl<T: 'static> Spans for PackedSpans<T>

Source§

const EMPTY: Self