flex_alloc::storage

Trait BufferHeader

Source
pub trait BufferHeader<T: ?Sized>:
    Copy
    + Debug
    + Sized {
    const EMPTY: Self;

    // Required methods
    fn is_empty(&self) -> bool;
    fn layout(&self) -> Result<Layout, LayoutError>;
    fn update_for_alloc(
        &mut self,
        ptr: NonNull<[u8]>,
        exact: bool,
    ) -> NonNull<T>;
}
Expand description

A header type used by a buffer to determine its size.

Required Associated Constants§

Source

const EMPTY: Self

The header value for a zero-sized buffer.

Required Methods§

Source

fn is_empty(&self) -> bool

Determine if this header represents a zero-sized buffer.

Source

fn layout(&self) -> Result<Layout, LayoutError>

Calculate the layout for the associated value.

Source

fn update_for_alloc(&mut self, ptr: NonNull<[u8]>, exact: bool) -> NonNull<T>

Update the header from the result of a new allocation.

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.

Implementors§

Source§

impl<T, I: Index> BufferHeader<T> for VecHeader<I>

Source§

const EMPTY: Self = _