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