#[non_exhaustive]pub enum PidlockError {
LockExists,
InvalidState,
IOError(Error),
InvalidPath(InvalidPathError),
}Expand description
Errors that may occur during the Pidlock lifetime.
This enum covers all possible error conditions that can occur when working with pidlocks, from path validation to I/O errors during lock operations.
§Examples
use pidlock::{Pidlock, PidlockError};
let temp_dir = std::env::temp_dir();
let lock_path = temp_dir.join("error_example.pid");
let mut lock = Pidlock::new_validated(&lock_path)?;
match lock.acquire() {
Ok(()) => {
println!("Lock acquired successfully");
lock.release()?;
}
Err(PidlockError::LockExists) => {
println!("Another process is holding the lock");
}
Err(PidlockError::InvalidState) => {
println!("Lock is in wrong state for this operation");
}
Err(e) => {
println!("Other error: {}", e);
}
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Trait Implementations§
Source§impl Debug for PidlockError
impl Debug for PidlockError
Source§impl Display for PidlockError
impl Display for PidlockError
Source§impl Error for PidlockError
impl Error for PidlockError
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 From<Error> for PidlockError
impl From<Error> for PidlockError
Source§impl From<InvalidPathError> for PidlockError
impl From<InvalidPathError> for PidlockError
Source§fn from(source: InvalidPathError) -> Self
fn from(source: InvalidPathError) -> Self
Converts to this type from the input type.
Source§impl PartialEq for PidlockError
impl PartialEq for PidlockError
Auto Trait Implementations§
impl Freeze for PidlockError
impl !RefUnwindSafe for PidlockError
impl Send for PidlockError
impl Sync for PidlockError
impl Unpin for PidlockError
impl !UnwindSafe for PidlockError
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