pub struct FixedPool<const SIZE: usize, const ALIGN: usize> { /* private fields */ }Expand description
Fixed-size memory pool for embedded systems
Provides O(1) allocation and deallocation from a pre-allocated buffer. Suitable for real-time systems with deterministic memory requirements.
Implementations§
Source§impl<const SIZE: usize, const ALIGN: usize> FixedPool<SIZE, ALIGN>
impl<const SIZE: usize, const ALIGN: usize> FixedPool<SIZE, ALIGN>
Sourcepub fn alloc(&self) -> Option<NonNull<u8>>
pub fn alloc(&self) -> Option<NonNull<u8>>
Allocate a block from the pool
Returns None if the pool is exhausted.
Sourcepub unsafe fn dealloc(&self, _ptr: NonNull<u8>)
pub unsafe fn dealloc(&self, _ptr: NonNull<u8>)
Deallocate a block back to the pool
§Safety
The pointer must have been allocated from this pool and not already freed.
Sourcepub unsafe fn reset(&self)
pub unsafe fn reset(&self)
Reset the pool, freeing all allocations
§Safety
Only call this when you’re certain no outstanding allocations exist.
Sourcepub const fn block_size(&self) -> usize
pub const fn block_size(&self) -> usize
Get block size
Trait Implementations§
impl<const SIZE: usize, const ALIGN: usize> Send for FixedPool<SIZE, ALIGN>
impl<const SIZE: usize, const ALIGN: usize> Sync for FixedPool<SIZE, ALIGN>
Auto Trait Implementations§
impl<const SIZE: usize, const ALIGN: usize> !Freeze for FixedPool<SIZE, ALIGN>
impl<const SIZE: usize, const ALIGN: usize> !RefUnwindSafe for FixedPool<SIZE, ALIGN>
impl<const SIZE: usize, const ALIGN: usize> Unpin for FixedPool<SIZE, ALIGN>
impl<const SIZE: usize, const ALIGN: usize> UnwindSafe for FixedPool<SIZE, ALIGN>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more