pub unsafe trait Storage<R: LayoutSpec>: Sized {
fn get_ptr(&self) -> *const u8;
fn get_mut_ptr(&mut self) -> *mut u8;
fn capacity(&self) -> usize;
}
Expand description
An interface to a contiguous memory block for use by data structures.
Required methods
Extracts a pointer to the beginning of the memory block.
Safety
Implementors must ensure the same pointer is returned every time this method is called throughout the block’s lifetime.
fn get_mut_ptr(&mut self) -> *mut u8
fn get_mut_ptr(&mut self) -> *mut u8
Extracts a mutable pointer to the beginning of the memory block.
Safety
Implementors must ensure the same pointer is returned every time this method is called throughout the block’s lifetime.
Returns the maximum number of items the memory block can hold.
Safety
What exactly constitutes an item depends on the argument type R
.
When called on a memory block with a layout matching
R::layout_with_capacity(n)
, this must return at most n
.
Implementors must ensure the same value is returned every time this method is called throughout the block’s lifetime.
Implementations on Foreign Types
sourceimpl<T: Sized> Storage<ArrayLayout<T>> for &mut [MaybeUninit<T>]
impl<T: Sized> Storage<ArrayLayout<T>> for &mut [MaybeUninit<T>]
sourceimpl<R: LayoutSpec, S: Storage<R>> Storage<R> for &mut S
impl<R: LayoutSpec, S: Storage<R>> Storage<R> for &mut S
sourceimpl<R: LayoutSpec, S: Storage<R>> Storage<R> for Box<S>
This is supported on crate feature alloc
only.
impl<R: LayoutSpec, S: Storage<R>> Storage<R> for Box<S>
alloc
only.Implementors
impl<A, const N: usize> Storage<ObjectLayout> for coca::object::InlineStorage<A, N>
unstable
only.impl<K, V, const N: usize> Storage<ListMapLayout<K, V>> for coca::collections::list_map::InlineStorage<K, V, N>
impl<R: LayoutSpec> Storage<R> for AllocStorage<R>
alloc
only.