devela::_dep::rkyv::ser

Trait Allocator

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> ;
}
Available on crate feature dep_rkyv only.
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§

unsafe fn push_alloc(&mut self, layout: Layout) -> Result<NonNull<[u8]>, E>

Allocates scratch space of the requested size.

§Safety

layout must have non-zero size.

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.
  • layout must be the same layout that was used to allocate the block of memory for the given pointer.

Implementors§

§

impl<E> Allocator<E> for ArenaHandle<'_>

§

impl<E> Allocator<E> for SubAllocator<'_>
where E: Source,

§

impl<T, E> Allocator<E> for Strategy<T, E>
where T: Allocator<E>,

§

impl<T, E> Allocator<E> for AllocationTracker<T>
where T: Allocator<E>,

§

impl<W, A, S, E> Allocator<E> for Serializer<W, A, S>
where A: Allocator<E>,