Struct tame_index::utils::flock::LockOptions
source · pub struct LockOptions<'pb> { /* private fields */ }
Expand description
Provides options for creating a FileLock
Implementations§
source§impl<'pb> LockOptions<'pb>
impl<'pb> LockOptions<'pb>
sourcepub fn cargo_package_lock(root: Option<PathBuf>) -> Result<Self, Error>
pub fn cargo_package_lock(root: Option<PathBuf>) -> Result<Self, Error>
Creates a new Self
for locking cargo’s global package lock
If specified, the path is used as the root, otherwise it is rooted at
the path determined by $CARGO_HOME
Will attempt to acquire a shared lock rather than an exclusive one
sourcepub fn exclusive(self, shared_fallback: bool) -> Self
pub fn exclusive(self, shared_fallback: bool) -> Self
Will attempt to acquire an exclusive lock, which can optionally fallback to a shared lock if the lock file is for a read only filesystem
sourcepub fn try_lock(&self) -> Result<FileLock, Error>
pub fn try_lock(&self) -> Result<FileLock, Error>
Attempts to acquire a lock, but fails immediately if the lock is currently held
sourcepub fn lock(
&self,
wait: impl Fn(&Path) -> Option<Duration>
) -> Result<FileLock, Error>
pub fn lock( &self, wait: impl Fn(&Path) -> Option<Duration> ) -> Result<FileLock, Error>
Attempts to acquire a lock, waiting if the lock is currently held.
Unlike Self::try_lock
, if the lock is currently held, the specified
callback is called to inform the caller that a wait is about to
be performed, then waits for the amount of time specified by the return
of the callback, or infinitely in the case of None
.