Trait Storage

Source
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§

Source

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.

Source

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.

Source

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 &mut S

Source§

impl<R: LayoutSpec, S: Storage<R>> Storage<R> for Box<S>

Available on crate feature alloc only.
Source§

impl<T: Sized> Storage<ArrayLayout<T>> for &mut [MaybeUninit<T>]

Implementors§

Source§

impl<A, const N: usize> Storage<ObjectLayout> for coca::object::InlineStorage<A, N>

Available on crate feature unstable only.
Source§

impl<K, V, const N: usize> Storage<ListMapLayout<K, V>> for coca::collections::list_map::InlineStorage<K, V, N>

Source§

impl<R: LayoutSpec> Storage<R> for AllocStorage<R>

Available on crate feature alloc only.
Source§

impl<R: LayoutSpec> Storage<R> for ArenaStorage<'_, R>

Source§

impl<R: LayoutSpec, S: Storage<R>> Storage<R> for coca::arena::Box<'_, S>

Source§

impl<T, H: Handle, const N: usize> Storage<DirectPoolLayout<T, H>> for coca::collections::pool::direct::InlineStorage<T, H, N>

Source§

impl<T, H: Handle, const N: usize> Storage<PackedPoolLayout<T, H>> for coca::collections::pool::packed::InlineStorage<T, H, N>

Source§

impl<T, const C: usize> Storage<ArrayLayout<T>> for coca::storage::InlineStorage<T, C>