pub struct LockError { /* private fields */ }sealed only.Expand description
Why the pre-key’s pages are not locked in RAM. Returned by Prekey::lock_status.
Not fatal: the sealed types work the same either way. What is lost is the guarantee
that the pre-key never reaches the swap file. On Windows the usual cause is the
process working-set quota, which every VirtualLock in the process shares; on Unix it
is RLIMIT_MEMLOCK.
It is also returned, without asking the operating system, for a pre-key made with
Prekey::new_idle_noaccess on Windows, where a no-access page cannot stay locked, and
in a fork() child of the process that made the pre-key, which does not inherit its lock.
Carries the operating system’s error code, never an address.
§Example
Report the reason, and raise the quota where it is the cause:
use secure_gate::Prekey;
let prekey = Prekey::new();
match prekey.lock_status() {
Ok(()) => {}
// ERROR_WORKING_SET_QUOTA: every `VirtualLock` in a Windows process shares the
// working-set quota (about eleven pre-keys under the default). Raise it at startup
// with `SetProcessWorkingSetSize` if the application holds more.
Err(why) if why.raw_os_error() == Some(1453) => eprintln!("raise the quota: {why}"),
Err(why) => eprintln!("sealed secrets work, but may reach swap: {why}"),
}Implementations§
Source§impl LockError
impl LockError
Sourcepub fn raw_os_error(&self) -> Option<i32>
pub fn raw_os_error(&self) -> Option<i32>
The operating system’s error code (GetLastError on Windows, errno on Unix), when
the lock was attempted and refused.
Sourcepub fn idle_noaccess(&self) -> bool
pub fn idle_noaccess(&self) -> bool
true when locking was not attempted because the pre-key was made with
Prekey::new_idle_noaccess on Windows: a no-access page leaves the process’s
working set, and its lock with it.
Trait Implementations§
impl Copy for LockError
impl Eq for LockError
Source§impl Error for LockError
impl Error for LockError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()