pub enum LockError {
Held {
kind: LockKind,
path: PathBuf,
holder: Option<Box<LockHolder>>,
refused_with: Option<i32>,
},
Io {
path: PathBuf,
source: Error,
},
Identity {
kind: LockKind,
source: ProcessError,
},
}Expand description
Something went wrong taking or inspecting a lock.
Variants§
Held
Somebody else has it.
Fields
path: PathBufWhere the lock file is, so the message is actionable on a host with a non-default layout.
holder: Option<Box<LockHolder>>Who holds it, when the record could be read. None is not the same
as “nobody”: it means the holder had not finished identifying
itself, which is a race of microseconds and not a reason to proceed.
Boxed because this variant travels inside a Result that e1
carries across a spawn_blocking boundary, and an inline
LockHolder makes that Err large enough for clippy’s
result_large_err to refuse the build. The indirection costs one
allocation on a path that has already lost a lock race.
refused_with: Option<i32>The operating system code the refusal actually carried.
§Why an errno is in a user-facing message
This variant has two causes that look identical once it is constructed: the lock is genuinely somebody else’s, or the operating system said “would block” for a reason this code does not model. The second is not hypothetical — a refusal that no reading of this module explains has been seen in CI on both Unix platforms, for a lock the same process had just released, and there was nothing in the message to tell the two apart.
Carrying the raw code costs a few characters and turns the next
occurrence from a mystery into a report. None where the platform
excluded at the open rather than at the lock call.
Io
The lock file could not be opened, read, or written.
Identity
The holder’s own identity could not be read, so it could not record who it is.
Trait Implementations§
Source§impl Error for LockError
impl Error for LockError
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()