pub unsafe trait Container<T> {
    type Internal;

    // Required methods
    fn into_internal(self) -> Self::Internal;
    unsafe fn from_internal(this: Self::Internal) -> Self;
    fn as_mut_ptr(this: &Self::Internal) -> *mut MaybeUninit<T>;
    fn len(this: &Self::Internal) -> usize;
}
Expand description

Abstract container for the ring buffer.

Container items must be stored as a contiguous array.

Safety

Self::len/[Self::is_empty] must always return the same value.

Container must not cause data race on concurrent [Self::as_mut_slice]/Self::as_mut_ptr calls.

Required Associated Types§

source

type Internal

Internal representation of the container.

Must not be aliased with its content.

Required Methods§

source

fn into_internal(self) -> Self::Internal

Transform container to internal representation.

source

unsafe fn from_internal(this: Self::Internal) -> Self

Restore container from internal representation.

Safety

this must be valid.

source

fn as_mut_ptr(this: &Self::Internal) -> *mut MaybeUninit<T>

Return pointer to the beginning of the container items.

source

fn len(this: &Self::Internal) -> usize

Length of the container.

Implementations on Foreign Types§

source§

impl<'a, T> Container<T> for &'a mut [MaybeUninit<T>]

§

type Internal = (*mut MaybeUninit<T>, usize)

source§

fn into_internal(self) -> Self::Internal

source§

unsafe fn from_internal(this: Self::Internal) -> Self

source§

fn as_mut_ptr(this: &Self::Internal) -> *mut MaybeUninit<T>

source§

fn len(this: &Self::Internal) -> usize

source§

impl<T> Container<T> for Vec<MaybeUninit<T>>

§

type Internal = Vec<MaybeUninit<T>, Global>

source§

fn into_internal(self) -> Self::Internal

source§

unsafe fn from_internal(this: Self::Internal) -> Self

source§

fn as_mut_ptr(this: &Self::Internal) -> *mut MaybeUninit<T>

source§

fn len(this: &Self::Internal) -> usize

source§

impl<T, const N: usize> Container<T> for [MaybeUninit<T>; N]

§

type Internal = UnsafeCell<[MaybeUninit<T>; N]>

source§

fn into_internal(self) -> Self::Internal

source§

unsafe fn from_internal(this: Self::Internal) -> Self

source§

fn as_mut_ptr(this: &Self::Internal) -> *mut MaybeUninit<T>

source§

fn len(_: &Self::Internal) -> usize

Implementors§