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
.
Auto Trait Implementations§
impl<'pb> Freeze for LockOptions<'pb>
impl<'pb> RefUnwindSafe for LockOptions<'pb>
impl<'pb> Send for LockOptions<'pb>
impl<'pb> Sync for LockOptions<'pb>
impl<'pb> Unpin for LockOptions<'pb>
impl<'pb> UnwindSafe for LockOptions<'pb>
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more