pub struct BrandedBox<'brand, 'heap, T, P = StandardPolicy, B = MemoryBackendWrapper>{ /* private fields */ }Expand description
A uniquely owned, safe pointer to heap-allocated memory of type T from a Heap.
Automatically drops T and deallocates the memory back to the heap on drop.
Implementations§
Source§impl<'brand, 'heap, T, P, B> BrandedBox<'brand, 'heap, T, P, B>
impl<'brand, 'heap, T, P, B> BrandedBox<'brand, 'heap, T, P, B>
Sourcepub fn new<Permit>(
heap: &'heap Heap<'brand, P, B>,
permit: Permit,
val: T,
) -> Option<BrandedBox<'brand, 'heap, T, P, B>>where
Permit: ReadPermit<'brand>,
pub fn new<Permit>(
heap: &'heap Heap<'brand, P, B>,
permit: Permit,
val: T,
) -> Option<BrandedBox<'brand, 'heap, T, P, B>>where
Permit: ReadPermit<'brand>,
Creates a new BrandedBox containing val allocated from the given Heap.
Source§impl<'brand, 'heap, T, P, B> BrandedBox<'brand, 'heap, T, P, B>
impl<'brand, 'heap, T, P, B> BrandedBox<'brand, 'heap, T, P, B>
Sourcepub fn into_raw(self) -> BrandedBlock<'brand, T>
pub fn into_raw(self) -> BrandedBlock<'brand, T>
Consumes the BrandedBox, returning the wrapped raw block without dropping or deallocating.
Sourcepub fn into_cell(self) -> BrandedCell<'brand, T>
pub fn into_cell(self) -> BrandedCell<'brand, T>
Converts this BrandedBox into a shared BrandedCell.
The memory remains allocated until it is manually reclaimed.
Sourcepub unsafe fn from_cell(
heap: &'heap Heap<'brand, P, B>,
cell: BrandedCell<'brand, T>,
) -> BrandedBox<'brand, 'heap, T, P, B>
pub unsafe fn from_cell( heap: &'heap Heap<'brand, P, B>, cell: BrandedCell<'brand, T>, ) -> BrandedBox<'brand, 'heap, T, P, B>
Reconstructs a BrandedBox from a shared BrandedCell.
§Safety
The caller must ensure that no other copies of this BrandedCell (or pointers derived from it)
are active or will be used.
Sourcepub unsafe fn from_raw(
heap: &'heap Heap<'brand, P, B>,
block: BrandedBlock<'brand, T>,
) -> BrandedBox<'brand, 'heap, T, P, B>
pub unsafe fn from_raw( heap: &'heap Heap<'brand, P, B>, block: BrandedBlock<'brand, T>, ) -> BrandedBox<'brand, 'heap, T, P, B>
Reconstructs a BrandedBox from a raw block.
§Safety
The memory block must be initialized with a valid value of type T.
Source§impl<'brand, 'heap, T, P, B> BrandedBox<'brand, 'heap, T, P, B>
impl<'brand, 'heap, T, P, B> BrandedBox<'brand, 'heap, T, P, B>
Sourcepub fn clone_in<Permit>(
&self,
permit: &Permit,
) -> Option<BrandedBox<'brand, 'heap, T, P, B>>where
&'token Permit: for<'token> ReadPermit<'brand>,
pub fn clone_in<Permit>(
&self,
permit: &Permit,
) -> Option<BrandedBox<'brand, 'heap, T, P, B>>where
&'token Permit: for<'token> ReadPermit<'brand>,
Clones the box using the given allocator read permit.
Returns None if allocation fails.