[−][src]Struct advisory_lock::AdvisoryFileLock
An advisory lock for files.
An advisory lock provides a mutual-exclusion mechanism among processes which explicitly acquires and releases the lock. Processes that are not aware of the lock will ignore it.
AdvisoryFileLock
provides following features:
- Blocking or non-blocking operations.
- Shared or exclusive modes.
- All operations are thread-safe.
Notes
AdvisoryFileLock
has following limitations:
- Locks are allowed only on files, but not directories.
Implementations
impl AdvisoryFileLock
[src]
pub fn new<P: AsRef<Path>>(
path: P,
file_lock_mode: FileLockMode
) -> Result<Self, FileLockError>
[src]
path: P,
file_lock_mode: FileLockMode
) -> Result<Self, FileLockError>
Create a new FileLock
.
pub fn is_shared(&self) -> bool
[src]
Return true
if the advisory lock is acquired by shared mode.
pub fn is_exclusive(&self) -> bool
[src]
Return true
if the advisory lock is acquired by exclusive mode.
pub fn lock(&mut self) -> Result<(), FileLockError>
[src]
Acquire the advisory file lock.
lock
is blocking; it will block the current thread until it succeeds or errors.
pub fn try_lock(&mut self) -> Result<(), FileLockError>
[src]
Try to acquire the advisory file lock.
try_lock
returns immediately.
pub fn unlock(&mut self) -> Result<(), FileLockError>
[src]
Trait Implementations
impl Drop for AdvisoryFileLock
[src]
Auto Trait Implementations
impl RefUnwindSafe for AdvisoryFileLock
impl Send for AdvisoryFileLock
impl Sync for AdvisoryFileLock
impl Unpin for AdvisoryFileLock
impl UnwindSafe for AdvisoryFileLock
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,