pub struct Lock {
_file: File,
path: PathBuf,
}Expand description
An exclusive advisory lock released when dropped or when the process exits.
The lock file remains on disk. Acquisition therefore cannot race with deletion and inode replacement.
Fields§
§_file: File§path: PathBufImplementations§
Source§impl Lock
impl Lock
Sourcepub fn try_acquire(path: &Path) -> Result<Self, LockError>
pub fn try_acquire(path: &Path) -> Result<Self, LockError>
Attempt to acquire an exclusive advisory lock without waiting.
The lock is tied to the open file handle. A crashed process releases the operating-system lock automatically. Timestamp-based stale-lock recovery is neither required nor safe.
§Errors
Returns LockError::is_busy when another process owns the lock.
Opening and locking failures are returned with path context.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Lock
impl RefUnwindSafe for Lock
impl Send for Lock
impl Sync for Lock
impl Unpin for Lock
impl UnsafeUnpin for Lock
impl UnwindSafe for Lock
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