pub struct LockedBuffer { /* private fields */ }Expand description
A memory buffer that is:
- mlock’d on Unix (pinned in RAM, never swapped to disk)
- Zeroized on drop (all bytes set to 0)
This ensures plaintext data never touches disk, even under memory pressure.
Implementations§
Source§impl LockedBuffer
impl LockedBuffer
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Allocate a new locked buffer. Memory is immediately mlock’d.
Sourcepub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
pub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
Get a mutable reference to the buffer contents
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn is_locked(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LockedBuffer
impl RefUnwindSafe for LockedBuffer
impl Send for LockedBuffer
impl Sync for LockedBuffer
impl Unpin for LockedBuffer
impl UnsafeUnpin for LockedBuffer
impl UnwindSafe for LockedBuffer
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