pub unsafe trait Allocator<E = <Self as Fallible>::Error> {
// Required methods
unsafe fn push_alloc(&mut self, layout: Layout) -> Result<NonNull<[u8]>, E>;
unsafe fn pop_alloc(
&mut self,
ptr: NonNull<u8>,
layout: Layout,
) -> Result<(), E>;
}Expand description
A serializer that can allocate scratch space.
§Safety
push_alloc must return a pointer to unaliased memory which fits the
provided layout.
Required Methods§
Sourceunsafe fn pop_alloc(
&mut self,
ptr: NonNull<u8>,
layout: Layout,
) -> Result<(), E>
unsafe fn pop_alloc( &mut self, ptr: NonNull<u8>, layout: Layout, ) -> Result<(), E>
Deallocates previously allocated scratch space.
§Safety
- The allocations pushed on top of the given allocation must not be
popped after calling
pop_alloc. layoutmust be the same layout that was used to allocate the block of memory for the given pointer.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".