pub struct ProcessLock(/* private fields */);Expand description
An exclusive OS file lock, released when this value is dropped.
Every participant must use the same persistent path in an application-owned directory. Neither this type nor a caller may unlink or replace the lock file: another process could still hold a lock on the original inode. Keep this guard alive through endpoint cleanup and the work it protects. Use separate paths for daemon ownership and upgrade serialization.
Implementations§
Source§impl ProcessLock
impl ProcessLock
Sourcepub fn try_acquire(path: impl AsRef<Path>) -> Result<Option<Self>>
pub fn try_acquire(path: impl AsRef<Path>) -> Result<Option<Self>>
Acquire without waiting, creating the file if necessary.
Returns Ok(None) only for contention; filesystem and locking failures
remain errors. The parent directory must already exist.
Sourcepub fn try_from_file(file: File) -> Result<Option<Self>>
pub fn try_from_file(file: File) -> Result<Option<Self>>
Lock an already-open file. This preserves a consumer’s secure open policy.
Trait Implementations§
Source§impl Debug for ProcessLock
impl Debug for ProcessLock
Source§impl Drop for ProcessLock
impl Drop for ProcessLock
Auto Trait Implementations§
impl Freeze for ProcessLock
impl RefUnwindSafe for ProcessLock
impl Send for ProcessLock
impl Sync for ProcessLock
impl Unpin for ProcessLock
impl UnsafeUnpin for ProcessLock
impl UnwindSafe for ProcessLock
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