pub unsafe trait Storage<R: LayoutSpec>: Sized {
// Required methods
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§
Sourcefn get_ptr(&self) -> *const u8
fn get_ptr(&self) -> *const u8
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.
Sourcefn 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.
Sourcefn capacity(&self) -> usize
fn capacity(&self) -> usize
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<R: LayoutSpec, S: Storage<R>> Storage<R> for Box<S>
Available on crate feature alloc
only.
impl<R: LayoutSpec, S: Storage<R>> Storage<R> for Box<S>
alloc
only.Source§impl<T: Sized> Storage<ArrayLayout<T>> for &mut [MaybeUninit<T>]
impl<T: Sized> Storage<ArrayLayout<T>> for &mut [MaybeUninit<T>]
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.