pub struct Alloc64;Expand description
§Alloc64
Global, zero-sized allocator that enforces 64-bit alignment.
§Behaviour
Hooks into Vec64
- Calls Vec64::allocate() when allocating new memory.
- Calls Vec64::grow() when reallocation is needed.
- Calls Vec64::deallocate() when the vector is dropped. etc, ensuring these calls go through the alignment-enforcing logic.
§Purpose
Guarantees starting pointer alignment for all allocations it manages including allocations due to growth, mutation, extension, and insertion—in all scenarios except for zero-sized types (ZSTs) and capacity 0.
§Padding
This allocator does not pad data automatically - it’s purpose is to ensure starting alignment for the memory allocation. When ‘flatbuffering’ multiple buffers, e.g., over the network, or as part of framed payloads, that you later plan to “steal”, for zero-copy memory access, keep in mind that manual padding may be required to ensure all relevant sub-elements also start on a 64-byte boundary.
Trait Implementations§
Source§impl Allocator for Alloc64
impl Allocator for Alloc64
Source§fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api)
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
allocator_api)Allocates memory with at least 64-byte alignment.
Source§fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api)
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
allocator_api)Allocates zero-initialised memory with 64-byte alignment.
Source§unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
🔬This is a nightly-only experimental API. (allocator_api)
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
allocator_api)Deallocates memory with alignment correction.
Source§unsafe fn grow(
&self,
ptr: NonNull<u8>,
old: Layout,
new: Layout,
) -> Result<NonNull<[u8]>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api)
unsafe fn grow( &self, ptr: NonNull<u8>, old: Layout, new: Layout, ) -> Result<NonNull<[u8]>, AllocError>
allocator_api)Grows an existing allocation while preserving 64-byte alignment.
Source§unsafe fn shrink(
&self,
ptr: NonNull<u8>,
old: Layout,
new: Layout,
) -> Result<NonNull<[u8]>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api)
unsafe fn shrink( &self, ptr: NonNull<u8>, old: Layout, new: Layout, ) -> Result<NonNull<[u8]>, AllocError>
allocator_api)Shrinks an allocation while preserving 64-byte alignment.
Source§unsafe fn grow_zeroed(
&self,
ptr: NonNull<u8>,
old: Layout,
new: Layout,
) -> Result<NonNull<[u8]>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api)
unsafe fn grow_zeroed( &self, ptr: NonNull<u8>, old: Layout, new: Layout, ) -> Result<NonNull<[u8]>, AllocError>
allocator_api)Grows the allocation to a new layout and zero-initialises any newly allocated region. Existing data is preserved; the new memory is zeroed.
impl Copy for Alloc64
Auto Trait Implementations§
impl Freeze for Alloc64
impl RefUnwindSafe for Alloc64
impl Send for Alloc64
impl Sync for Alloc64
impl Unpin for Alloc64
impl UnwindSafe for Alloc64
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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