[][src]Struct swim_mem::alloc::Pack

pub struct Pack<'a> { /* fields omitted */ }

Linear allocator for a fixed-size memory block.

A pack allocates space by advancing a pointer into its memory block, similar to stack allocation. Packs only reclaim space when the most recent allocation drops, and when the whole pack drops.

Methods

impl<'a> Pack<'a>[src]

pub fn new(block: Block<'a>) -> &'a Pack<'a>[src]

Constructs a Pack in a memory block.

pub fn from_block(block: Block<'a>, header_size: usize) -> *mut Pack<'a>[src]

Constructs a Pack in a memory block with a reserved header.

Safety

Assumes header_size is large enough to hold the Pack header.

pub fn size(&self) -> usize[src]

Returns the total number of bytes in the memory block, including the pack header.

pub fn free(&self) -> usize[src]

Returns the number of free bytes available for allocation in this Pack.

pub fn live(&self) -> usize[src]

Return the number of live allocations in this Pack.

pub fn used(&self) -> usize[src]

Returns the number of bytes currently allocated in this Pack.

pub unsafe fn as_block(&mut self) -> Block<'a>[src]

Returns the memory block managed by this Pack.

Trait Implementations

impl<'a> Hold<'a> for Pack<'a>[src]

unsafe fn realloc(
    &self,
    block: Block<'a>,
    layout: Layout
) -> Result<Block<'a>, HoldError>
[src]

Attempts to resize a memory block allocated by this Hold to fit a new layout. Returns Ok with the resized memory block on success; returns a HoldError on failure. Read more

impl<'a> Reify<'a, dyn Hold<'a> + 'a> for Pack<'a>[src]

Auto Trait Implementations

impl<'a> !Send for Pack<'a>

impl<'a> !Sync for Pack<'a>

Blanket Implementations

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]