Struct secmem_alloc::zeroizing_alloc::ZeroizeAlloc
source · [−]pub struct ZeroizeAlloc<BackendAlloc, Z: MemZeroizer = DefaultMemZeroizer> { /* private fields */ }
Expand description
Wrapper around an allocator which zeroizes memory on deallocation. See the module level documentation.
If debug assertions are enabled, some of the safety requirement for using an allocator are checked.
Implementations
sourceimpl<A> ZeroizeAlloc<A>
impl<A> ZeroizeAlloc<A>
sourceimpl<A, Z: MemZeroizer> ZeroizeAlloc<A, Z>
impl<A, Z: MemZeroizer> ZeroizeAlloc<A, Z>
sourcepub fn with_zeroizer(backend_alloc: A, zeroizer: Z) -> Self
pub fn with_zeroizer(backend_alloc: A, zeroizer: Z) -> Self
Create a zeroizing allocator using backend_alloc
for allocations and
zeroizer
to zeroize memory upon deallocation.
sourceimpl<A, Z: MemZeroizer + Default> ZeroizeAlloc<A, Z>
impl<A, Z: MemZeroizer + Default> ZeroizeAlloc<A, Z>
sourcepub fn with_default_zeroizer(backend_alloc: A) -> Self
pub fn with_default_zeroizer(backend_alloc: A) -> Self
Create a zeroizing allocator using backend_alloc
for allocations and
zeroizer
to zeroize memory upon deallocation.
Trait Implementations
sourceimpl<B, Z> Allocator for ZeroizeAlloc<B, Z> where
B: Allocator,
Z: MemZeroizer,
impl<B, Z> Allocator for ZeroizeAlloc<B, Z> where
B: Allocator,
Z: MemZeroizer,
sourcefn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
allocator_api
)Attempts to allocate a block of memory. Read more
sourcefn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
allocator_api
)Behaves like allocate
, but also ensures that the returned memory is zero-initialized. Read more
sourceunsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
allocator_api
)Deallocates the memory referenced by ptr
. Read more
sourceunsafe fn grow(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn grow(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout
) -> Result<NonNull<[u8]>, AllocError>
allocator_api
)Attempts to extend the memory block. Read more
sourceunsafe fn grow_zeroed(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn grow_zeroed(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout
) -> Result<NonNull<[u8]>, AllocError>
allocator_api
)Behaves like grow
, but also ensures that the new contents are set to zero before being
returned. Read more
sourceimpl<BackendAlloc: Debug, Z: Debug + MemZeroizer> Debug for ZeroizeAlloc<BackendAlloc, Z>
impl<BackendAlloc: Debug, Z: Debug + MemZeroizer> Debug for ZeroizeAlloc<BackendAlloc, Z>
sourceimpl<BackendAlloc: Default, Z: Default + MemZeroizer> Default for ZeroizeAlloc<BackendAlloc, Z>
impl<BackendAlloc: Default, Z: Default + MemZeroizer> Default for ZeroizeAlloc<BackendAlloc, Z>
sourcefn default() -> ZeroizeAlloc<BackendAlloc, Z>
fn default() -> ZeroizeAlloc<BackendAlloc, Z>
Returns the “default value” for a type. Read more
sourceimpl<B, Z> GlobalAlloc for ZeroizeAlloc<B, Z> where
B: GlobalAlloc,
Z: MemZeroizer,
impl<B, Z> GlobalAlloc for ZeroizeAlloc<B, Z> where
B: GlobalAlloc,
Z: MemZeroizer,
sourceunsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
Allocate memory as described by the given layout
. Read more
sourceunsafe fn dealloc(&self, ptr: *mut u8, layout: Layout)
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout)
Deallocate the block of memory at the given ptr
pointer with the given layout
. Read more
Auto Trait Implementations
impl<BackendAlloc, Z> RefUnwindSafe for ZeroizeAlloc<BackendAlloc, Z> where
BackendAlloc: RefUnwindSafe,
Z: RefUnwindSafe,
impl<BackendAlloc, Z> Send for ZeroizeAlloc<BackendAlloc, Z> where
BackendAlloc: Send,
Z: Send,
impl<BackendAlloc, Z> Sync for ZeroizeAlloc<BackendAlloc, Z> where
BackendAlloc: Sync,
Z: Sync,
impl<BackendAlloc, Z> Unpin for ZeroizeAlloc<BackendAlloc, Z> where
BackendAlloc: Unpin,
Z: Unpin,
impl<BackendAlloc, Z> UnwindSafe for ZeroizeAlloc<BackendAlloc, Z> where
BackendAlloc: UnwindSafe,
Z: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more