ringbuf::storage

Trait Storage

Source
pub unsafe trait Storage {
    type Item: Sized;

    // Required methods
    fn len(&self) -> usize;
    fn as_mut_ptr(&self) -> *mut MaybeUninit<Self::Item>;

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn as_ptr(&self) -> *const MaybeUninit<Self::Item> { ... }
    unsafe fn slice(&self, range: Range<usize>) -> &[MaybeUninit<Self::Item>] { ... }
    unsafe fn slice_mut(
        &self,
        range: Range<usize>,
    ) -> &mut [MaybeUninit<Self::Item>] { ... }
}
Expand description

Abstract storage for the ring buffer.

Storage items must be stored as a contiguous array.

§Safety

Must not alias with its contents (it must be safe to store mutable references to storage itself and to its data at the same time).

Self::as_mut_ptr must point to underlying data.

Self::len must always return the same value.

Required Associated Types§

Source

type Item: Sized

Stored item.

Required Methods§

Source

fn len(&self) -> usize

Length of the storage.

Source

fn as_mut_ptr(&self) -> *mut MaybeUninit<Self::Item>

Return mutable pointer to the beginning of the storage items.

Provided Methods§

Source

fn is_empty(&self) -> bool

Source

fn as_ptr(&self) -> *const MaybeUninit<Self::Item>

Return pointer to the beginning of the storage items.

Source

unsafe fn slice(&self, range: Range<usize>) -> &[MaybeUninit<Self::Item>]

Returns a mutable slice of storage in specified range.

§Safety

Slice must not overlab with existing mutable slices.

Non-Sync items must not be accessed concurrently.

Source

unsafe fn slice_mut( &self, range: Range<usize>, ) -> &mut [MaybeUninit<Self::Item>]

Returns a mutable slice of storage in specified range.

§Safety

Slices must not overlap.

Implementors§

Source§

impl<'a, T> Storage for Ref<'a, T>

Source§

type Item = T

Source§

impl<T> Storage for Heap<T>

Source§

type Item = T

Source§

impl<T> Storage for Slice<T>

Source§

type Item = T

Source§

impl<T, const N: usize> Storage for Array<T, N>

Source§

type Item = T