pub struct ManualAllocator(/* private fields */);Expand description
A singleton allocator that carries no underlying BStack and never
allocates.
ManualAllocator is for code that wants the BStackSlice type — a
typed (offset, len) handle with the standard slice interface — but
manages positions on the backing BStack directly, without delegating
region tracking to an allocator.
§Behaviour
| Operation | Behaviour |
|---|---|
alloc | Returns Err(Unsupported) |
realloc | Returns Err(Unsupported) |
dealloc | Returns Ok(()) (no-op) |
len | Returns Err(Unsupported) |
is_empty | Returns Err(Unsupported) |
stack | Panics — no backing stack |
into_stack | Panics — no backing stack |
§Singleton
Obtain the allocator via ManualAllocator::get, which always returns the
same &'static ManualAllocator. Direct construction is intentionally
prevented to make the singleton nature explicit and to discourage treating
the type as a regular value.
§Creating slices
Use BStackSlice::from_raw_parts to create a slice at a known position:
let slice = unsafe { BStackSlice::from_raw_parts(ManualAllocator::get(), offset, len) };Or reconstruct one from a serialised token:
let slice = unsafe { BStackSlice::from_bytes(ManualAllocator::get(), token) };Because there is no backing BStack, calling BStackSlice::read or
BStackSlice::write on such a slice will panic. The slice is useful
as a typed coordinate — serialised, compared, sorted, stored alongside
other data — while all I/O is performed directly on the BStack via
BStack::get / BStack::set at the offsets the slice describes.
§Manual position management
Since no allocator tracks ownership, the caller is entirely responsible for
ensuring that every (offset, len) pair describes a valid, live region
within the backing BStack, that regions do not overlap unless
intentional, and that the BStack is not truncated beneath a live slice.
No bookkeeping or validation is performed on construction.
Implementations§
Trait Implementations§
Source§impl BStackAllocator for ManualAllocator
impl BStackAllocator for ManualAllocator
Source§fn into_stack(self) -> BStack ⓘ
fn into_stack(self) -> BStack ⓘ
Always panics — ManualAllocator has no backing BStack to return.
Source§fn alloc(&self, _len: u64) -> Result<BStackSlice<'_, Self>>
fn alloc(&self, _len: u64) -> Result<BStackSlice<'_, Self>>
Always returns Err(Unsupported).
Construct slices manually with BStackSlice::from_raw_parts instead.
Source§fn realloc<'a>(
&'a self,
_slice: BStackSlice<'a, Self>,
_new_len: u64,
) -> Result<BStackSlice<'a, Self>>
fn realloc<'a>( &'a self, _slice: BStackSlice<'a, Self>, _new_len: u64, ) -> Result<BStackSlice<'a, Self>>
Always returns Err(Unsupported).
Manage slice positions manually by creating new BStackSlice handles.
Source§fn dealloc(&self, _slice: BStackSlice<'_, Self>) -> Result<()>
fn dealloc(&self, _slice: BStackSlice<'_, Self>) -> Result<()>
Always returns Ok(()).
There is nothing to free — ownership of the region is the caller’s responsibility.
Source§fn is_empty(&self) -> Result<bool>
fn is_empty(&self) -> Result<bool>
Always returns Err(Unsupported) — there is no backing BStack.