[−][src]Struct swim_mem::alloc::Pack
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 alloc(&self, layout: Layout) -> Result<Block<'a>, HoldError>
[src]
unsafe fn dealloc(&self, block: Block<'a>) -> usize
[src]
unsafe fn resize(
&self,
block: Block<'a>,
layout: Layout
) -> Result<Block<'a>, HoldError>
[src]
&self,
block: Block<'a>,
layout: Layout
) -> Result<Block<'a>, HoldError>
unsafe fn realloc(
&self,
block: Block<'a>,
layout: Layout
) -> Result<Block<'a>, HoldError>
[src]
&self,
block: Block<'a>,
layout: Layout
) -> Result<Block<'a>, HoldError>
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
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,