pub struct AllocationBuffer { /* private fields */ }Expand description
The memory a ReceiveAllocator returns for one AllocationRequest.
§Threading
A buffer is Send: a policy returns it on an SDK thread, and the SDK
may free it on another. It is not Sync, because it can hold an
ExternalAllocation, which needs only to be Send, and
capacity asks that allocation through a shared
reference.
Implementations§
Source§impl AllocationBuffer
impl AllocationBuffer
Sourcepub fn zeroed(request: AllocationRequest) -> Result<Self>
pub fn zeroed(request: AllocationRequest) -> Result<Self>
Allocate zeroed, 64-byte-aligned memory of the request’s minimum size.
§Errors
Error::AllocationFailed when the global
allocator cannot supply that much memory.
Sourcepub fn from_external<S: ExternalAllocation>(
request: AllocationRequest,
storage: S,
) -> Result<Self, Rejected<S>>
pub fn from_external<S: ExternalAllocation>( request: AllocationRequest, storage: S, ) -> Result<Self, Rejected<S>>
Lend memory through an arbitrary application-owned handle.
Boxes the handle once per buffer. For a pool whose block can be
described as plain data, from_pool avoids that allocation.
§Errors
Returns the memory with Error::InvalidInput
when it is smaller than the request’s minimum, larger than its capacity
limit, or not aligned to 64 bytes, so that a pool gets its buffer back.
Sourcepub unsafe fn from_pool<P: ExternalPool>(
request: AllocationRequest,
pool: &Arc<P>,
block: PoolBlock,
) -> Result<Self, Rejected<PoolBlock>>
pub unsafe fn from_pool<P: ExternalPool>( request: AllocationRequest, pool: &Arc<P>, block: PoolBlock, ) -> Result<Self, Rejected<PoolBlock>>
Lend a plain pool block without allocating or calling pool accessors.
Clones the pool’s Arc; the buffer releases the block exactly once on
drop, including when registry publication refuses it. Constructor failure
returns the block in Rejected without releasing it.
§Safety
If validation succeeds, block must name an initialized, writable,
CPU-addressable allocation from pool, aligned to 64 bytes and valid
for its stated capacity. Until pool.release(block), nothing else may
read, write, free or remap it, or lend another copy of this descriptor.
The block must remain valid even if the caller drops its own pool Arc.
A PoolBlock is Copy and can be forged; validation checks geometry only,
so this per-loan ownership obligation cannot be proved by a safe constructor.
§Errors
Returns the unchanged block with Error::InvalidInput
for insufficient/excessive capacity or misalignment, as from_external does.