Skip to main content

Lock

Trait Lock 

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

Protected region of memory that can be locked.

Required Methods§

Source

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

Locks a region of memory, using 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, for example because the process has reached its locked-memory limit.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<A: Zeroize + Bytes + Default, PM: ProtectMode> Lock<A, PM> for Protected<A, PM, Unlocked>