pub struct FileLock { /* private fields */ }Expand description
RAII file lock using flock(2).
Acquires an exclusive lock on a .lock file adjacent to the target path.
The lock is released when the guard is dropped.
Implementations§
Source§impl FileLock
impl FileLock
Sourcepub fn acquire(path: &Path) -> Result<Self>
pub fn acquire(path: &Path) -> Result<Self>
Acquire an exclusive lock for operations on path.
Creates <path>.lock if it doesn’t exist, then acquires an exclusive
flock. Blocks until the lock is available.
Sourcepub fn try_acquire(path: &Path) -> Result<Option<Self>>
pub fn try_acquire(path: &Path) -> Result<Option<Self>>
Try to acquire the lock without blocking.
Returns None if another process holds the lock.
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