pub struct BumpArena { /* private fields */ }Expand description
A simple bump allocator for byte-slice entries.
Allocations are cheap (pointer-bump only). Deallocation is not
supported per-entry; call reset to reclaim the whole arena at once
(typically called after a batch eviction sweep).
Implementations§
Source§impl BumpArena
impl BumpArena
Sourcepub fn new(initial_capacity: usize) -> Self
pub fn new(initial_capacity: usize) -> Self
Create a new BumpArena with initial_capacity bytes pre-allocated.
Sourcepub fn alloc(&mut self, bytes: &[u8]) -> (usize, usize)
pub fn alloc(&mut self, bytes: &[u8]) -> (usize, usize)
Append bytes to the arena and return (offset, len).
Grows the backing vec if necessary.
Sourcepub fn get(&self, offset: usize, len: usize) -> &[u8] ⓘ
pub fn get(&self, offset: usize, len: usize) -> &[u8] ⓘ
Retrieve a byte slice stored at (offset, len).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BumpArena
impl RefUnwindSafe for BumpArena
impl Send for BumpArena
impl Sync for BumpArena
impl Unpin for BumpArena
impl UnsafeUnpin for BumpArena
impl UnwindSafe for BumpArena
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