Skip to main content

AllocationBuffer

Struct AllocationBuffer 

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn capacity(&self) -> usize

The size of the memory in bytes.

Trait Implementations§

Source§

impl Debug for AllocationBuffer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.