Skip to main content

Lockable

Trait Lockable 

Source
pub trait Lockable<A: Zeroize + Bytes> {
    // Required method
    fn mlock(self) -> Result<Protected<A, ReadWrite, Locked>, Error>;
}
Available on crate feature protected only.
Expand description

A region of memory that can be locked, but is not yet protected. In order to lock the memory, it may require making a copy.

Required Methods§

Source

fn mlock(self) -> Result<Protected<A, ReadWrite, Locked>, Error>

Consumes self, creates a new protected region of memory, and returns the result in a heap-allocated, page-aligned region of memory. The memory is locked with mlock() on UNIX, or VirtualLock() on Windows. By default, the protect mode is set to ReadWrite (i.e., no exec) using mprotect() on UNIX, or VirtualProtect() on Windows. On Linux, it will also set MADV_DONTDUMP using madvise().

§Errors

Returns error::Error::Io if the pages cannot be locked. A common cause is exceeding the process’s locked-memory limit.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Lockable<HeapBytes> for HeapBytes

Source§

impl<const LENGTH: usize> Lockable<HeapByteArray<LENGTH>> for HeapByteArray<LENGTH>