pub struct Arena<const N: usize> { /* private fields */ }Expand description
A statically-sized arena for allocation of byte buffers.
Implementations§
Source§impl<const N: usize> Arena<N>
impl<const N: usize> Arena<N>
Sourcepub fn alloc(&mut self, size: usize) -> Result<BufMut<'_>, AllocError>
pub fn alloc(&mut self, size: usize) -> Result<BufMut<'_>, AllocError>
Allocates a new chunk from this Arena.
Returns an AllocError if the given size exceeeds to amount of bytes this Arena can
still allocate.
Note that a zero-sized allocation will always suceed and a allocation greater than N will
always fail.
Sourcepub fn alloc_zeroed(&mut self, size: usize) -> Result<BufMut<'_>, AllocError>
pub fn alloc_zeroed(&mut self, size: usize) -> Result<BufMut<'_>, AllocError>
Allocates a new zeroed chunk from this Arena.
This method is equivalent to alloc, except that the returned buffer is zeroed.
Sourcepub unsafe fn get_unchecked(&self, index: Index) -> Buf<'_>
pub unsafe fn get_unchecked(&self, index: Index) -> Buf<'_>
Sourcepub fn get_mut(&mut self, index: Index) -> Option<BufMut<'_>>
pub fn get_mut(&mut self, index: Index) -> Option<BufMut<'_>>
Returns the chunk with the given Index.
Trait Implementations§
Auto Trait Implementations§
impl<const N: usize> Freeze for Arena<N>
impl<const N: usize> RefUnwindSafe for Arena<N>
impl<const N: usize> Send for Arena<N>
impl<const N: usize> Sync for Arena<N>
impl<const N: usize> Unpin for Arena<N>
impl<const N: usize> UnwindSafe for Arena<N>
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