pub enum MlockError {
PermissionDenied,
ResourceLimit,
InvalidArgument,
WouldBlock,
Unknown(i32),
}Expand description
Error type for memory locking operations.
Each variant includes remediation guidance in its Display implementation.
Variants§
PermissionDenied
Permission denied (EPERM).
The process lacks the CAP_IPC_LOCK capability.
§Remediation
- Run as root:
sudo ./daemon - Add capability:
sudo setcap cap_ipc_lock=+ep ./daemon - Docker:
docker run --cap-add=IPC_LOCK ...
ResourceLimit
Resource limit exceeded (ENOMEM).
Either:
RLIMIT_MEMLOCKis too low- Insufficient physical memory available
- Kernel cannot allocate tracking structures
§Remediation
- Raise limit:
ulimit -l unlimited - Docker:
docker run --ulimit memlock=-1:-1 ... - Systemd:
LimitMEMLOCK=infinityin unit file
InvalidArgument
Invalid argument (EINVAL).
Shouldn’t occur with this library unless using experimental flags on unsupported kernels.
WouldBlock
Operation would block (EAGAIN).
Some pages could not be locked. Typically occurs on macOS.
Unknown(i32)
Unknown error with errno value.
Contains the raw errno for debugging.
Implementations§
Source§impl MlockError
impl MlockError
Sourcepub const fn from_errno(errno: i32) -> Self
pub const fn from_errno(errno: i32) -> Self
Create an error from a raw errno value.
Sourcepub const fn is_permission_error(&self) -> bool
pub const fn is_permission_error(&self) -> bool
Check if this error indicates a permission issue.
Sourcepub const fn is_resource_limit(&self) -> bool
pub const fn is_resource_limit(&self) -> bool
Check if this error indicates a resource limit issue.
Trait Implementations§
Source§impl Clone for MlockError
impl Clone for MlockError
Source§fn clone(&self) -> MlockError
fn clone(&self) -> MlockError
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MlockError
impl Debug for MlockError
Source§impl Display for MlockError
impl Display for MlockError
Source§impl Error for MlockError
impl Error for MlockError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl PartialEq for MlockError
impl PartialEq for MlockError
impl Copy for MlockError
impl Eq for MlockError
impl StructuralPartialEq for MlockError
Auto Trait Implementations§
impl Freeze for MlockError
impl RefUnwindSafe for MlockError
impl Send for MlockError
impl Sync for MlockError
impl Unpin for MlockError
impl UnwindSafe for MlockError
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