pub struct ArenaAllocator { /* private fields */ }Expand description
Main arena allocator implementation
Implementations§
Source§impl ArenaAllocator
impl ArenaAllocator
Sourcepub fn new(
base_ptr: NonNull<u8>,
size: usize,
config: ArenaConfig,
) -> Result<Self, ArenaError>
pub fn new( base_ptr: NonNull<u8>, size: usize, config: ArenaConfig, ) -> Result<Self, ArenaError>
Create a new arena allocator
Sourcepub fn allocate(&mut self, size: usize) -> Result<NonNull<u8>, ArenaError>
pub fn allocate(&mut self, size: usize) -> Result<NonNull<u8>, ArenaError>
Allocate memory from the arena
Sourcepub fn allocate_tagged(
&mut self,
size: usize,
tag: String,
) -> Result<NonNull<u8>, ArenaError>
pub fn allocate_tagged( &mut self, size: usize, tag: String, ) -> Result<NonNull<u8>, ArenaError>
Allocate memory with a debug tag
Sourcepub fn allocate_aligned(
&mut self,
size: usize,
alignment: usize,
) -> Result<NonNull<u8>, ArenaError>
pub fn allocate_aligned( &mut self, size: usize, alignment: usize, ) -> Result<NonNull<u8>, ArenaError>
Allocate aligned memory
Sourcepub fn checkpoint(&mut self) -> Result<CheckpointHandle, ArenaError>
pub fn checkpoint(&mut self) -> Result<CheckpointHandle, ArenaError>
Create a checkpoint for later rollback
Sourcepub fn checkpoint_named(
&mut self,
name: String,
) -> Result<CheckpointHandle, ArenaError>
pub fn checkpoint_named( &mut self, name: String, ) -> Result<CheckpointHandle, ArenaError>
Create a named checkpoint
Sourcepub fn rollback(&mut self, handle: CheckpointHandle) -> Result<(), ArenaError>
pub fn rollback(&mut self, handle: CheckpointHandle) -> Result<(), ArenaError>
Rollback to a checkpoint
Sourcepub fn get_usage(&self) -> ArenaUsage
pub fn get_usage(&self) -> ArenaUsage
Get current usage information
Sourcepub fn get_stats(&self) -> &ArenaStats
pub fn get_stats(&self) -> &ArenaStats
Get statistics
Sourcepub fn get_allocations(&self) -> &[AllocationRecord]
pub fn get_allocations(&self) -> &[AllocationRecord]
Get allocation records (if tracking enabled)
Sourcepub fn get_checkpoints(&self) -> &[ArenaCheckpoint]
pub fn get_checkpoints(&self) -> &[ArenaCheckpoint]
Get checkpoints
Sourcepub fn contains_pointer(&self, ptr: NonNull<u8>) -> bool
pub fn contains_pointer(&self, ptr: NonNull<u8>) -> bool
Check if a pointer belongs to this arena
Sourcepub fn get_allocation_info(&self, ptr: NonNull<u8>) -> Option<&AllocationRecord>
pub fn get_allocation_info(&self, ptr: NonNull<u8>) -> Option<&AllocationRecord>
Get allocation info for a pointer (if tracking enabled)
Sourcepub fn validate(&self) -> Result<(), ArenaError>
pub fn validate(&self) -> Result<(), ArenaError>
Validate arena consistency
Sourcepub fn get_memory_layout(&self) -> MemoryLayout
pub fn get_memory_layout(&self) -> MemoryLayout
Get memory layout information
Trait Implementations§
impl Send for ArenaAllocator
impl Sync for ArenaAllocator
Auto Trait Implementations§
impl Freeze for ArenaAllocator
impl RefUnwindSafe for ArenaAllocator
impl Unpin for ArenaAllocator
impl UnwindSafe for ArenaAllocator
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> 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