[][src]Struct advisory_lock::AdvisoryFileLock

pub struct AdvisoryFileLock { /* fields omitted */ }

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]

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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.