pub struct GuardedMemory { /* private fields */ }Expand description
A guarded memory region that zeroizes on drop.
For enclave environments where sensitive data must be:
- Zeroized when no longer needed
- Tracked for lifetime management
- Protected from accidental copies
- Locked in RAM (when
mlockfeature is enabled)
Uses Box<[u8]> internally (not Vec<u8>) to guarantee the backing
pointer is never invalidated by reallocation — critical for mlock safety.
§Example
use chains_sdk::security::GuardedMemory;
let mut guard = GuardedMemory::new(32);
guard.as_mut()[..4].copy_from_slice(&[0xDE, 0xAD, 0xBE, 0xEF]);
// memory is automatically zeroized (and munlocked) when `guard` is droppedImplementations§
Trait Implementations§
Source§impl AsMut<[u8]> for GuardedMemory
impl AsMut<[u8]> for GuardedMemory
Source§impl AsRef<[u8]> for GuardedMemory
impl AsRef<[u8]> for GuardedMemory
Source§impl Debug for GuardedMemory
impl Debug for GuardedMemory
Auto Trait Implementations§
impl Freeze for GuardedMemory
impl RefUnwindSafe for GuardedMemory
impl Send for GuardedMemory
impl Sync for GuardedMemory
impl Unpin for GuardedMemory
impl UnsafeUnpin for GuardedMemory
impl UnwindSafe for GuardedMemory
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
Mutably borrows from an owned value. Read more
Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Upper case
letters are used (e.g. F9B4CA)