Trait rkyv::ser::ScratchSpace

source ·
pub trait ScratchSpace: Fallible {
    // Required methods
    unsafe fn push_scratch(
        &mut self,
        layout: Layout,
    ) -> Result<NonNull<[u8]>, Self::Error>;
    unsafe fn pop_scratch(
        &mut self,
        ptr: NonNull<u8>,
        layout: Layout,
    ) -> Result<(), Self::Error>;
}
Expand description

A serializer that can allocate scratch space.

Required Methods§

source

unsafe fn push_scratch( &mut self, layout: Layout, ) -> Result<NonNull<[u8]>, Self::Error>

Allocates scratch space of the requested size.

§Safety

layout must have non-zero size.

source

unsafe fn pop_scratch( &mut self, ptr: NonNull<u8>, layout: Layout, ) -> Result<(), Self::Error>

Deallocates previously allocated scratch space.

§Safety
  • ptr must be the scratch memory last allocated with push_scratch.
  • layout must be the same layout that was used to allocate that block of memory.

Implementors§