pub struct FileLock {
pub recovered_stale: Option<LockOwner>,
/* private fields */
}Expand description
Held until dropped (or the process dies).
Fields§
§recovered_stale: Option<LockOwner>Owner of a lock left behind by a process that is gone, when one was found.
Implementations§
Source§impl FileLock
impl FileLock
Sourcepub fn acquire(path: &Path, options: &LockOptions) -> Result<Self>
pub fn acquire(path: &Path, options: &LockOptions) -> Result<Self>
Exclusive lock, the first of the two lock primitives. Waits up to options.timeout
(Duration::ZERO tries once), then records this process as owner in <path>.owner.
Returns FsError::Locked (with the owner) or FsError::LockTimeout when busy.
Sourcepub fn try_acquire(path: &Path) -> Result<Self>
pub fn try_acquire(path: &Path) -> Result<Self>
Exclusive lock, failing immediately when busy. Shorthand for acquire with default options.
Shared lock, the second primitive: any number of shared holders may coexist, and an
exclusive holder excludes them all. Waits up to options.timeout. Writes no owner
record, so recovered_stale is always None.
pub fn path(&self) -> &Path
Sourcepub fn current_owner(lock_path: &Path) -> Option<LockOwner>
pub fn current_owner(lock_path: &Path) -> Option<LockOwner>
The holder recorded on disk for lock_path (diagnostics; may be stale).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileLock
impl RefUnwindSafe for FileLock
impl Send for FileLock
impl Sync for FileLock
impl Unpin for FileLock
impl UnsafeUnpin for FileLock
impl UnwindSafe for FileLock
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