pub struct Arena { /* private fields */ }Expand description
A bump allocator backing one request’s allocations.
alloc returns an unaligned byte cursor; callers responsible
for alignment. Drop releases all pages at once — no per-value
destructor is run, so callers must put only POD-shaped data
here today (slice-1 doesn’t actually allocate Values into the
arena; this is purely a lifecycle harness).
Implementations§
Source§impl Arena
impl Arena
Sourcepub fn alloc(&self, len: usize) -> &mut [u8] ⓘ
pub fn alloc(&self, len: usize) -> &mut [u8] ⓘ
Allocate len bytes from the arena. Returns a &mut [u8]
bound to the arena’s lifetime. Grows by appending a fresh
page if the request doesn’t fit in the active page.
Panics if len > PAGE_BYTES. Larger allocations would
require multi-page allocation (boxed slice). Out of scope
for the scaffolding — the IndexMap / VecDeque values the
arena will eventually carry are well under 64 KiB.
§Safety
The returned slice is uninitialized.
Sourcepub fn bytes_allocated(&self) -> usize
pub fn bytes_allocated(&self) -> usize
Total bytes allocated across all pages. Useful for tests
and a future arena.stat builtin that surfaces per-request
allocation pressure.
Sourcepub fn page_count(&self) -> usize
pub fn page_count(&self) -> usize
Page count. Tests use this to confirm grow-on-demand fires at the right thresholds.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Arena
impl !RefUnwindSafe for Arena
impl !Sync for Arena
impl Send for Arena
impl Unpin for Arena
impl UnsafeUnpin for Arena
impl UnwindSafe for Arena
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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