pub struct LockGuard { /* private fields */ }Expand description
RAII exclusive lock over a proper-lockfile-compatible lock directory.
Dropping the guard stops the mtime heartbeat (if any) and removes only the lock directory this guard created, and only while that directory is still the same filesystem identity captured at acquire time.
Implementations§
Source§impl LockGuard
impl LockGuard
Sourcepub fn acquire(target: impl AsRef<Path>) -> Result<Self, LockError>
pub fn acquire(target: impl AsRef<Path>) -> Result<Self, LockError>
Acquire an exclusive lock with the production default policy.
§Errors
Returns LockError::Contended when another live holder owns the lock
after the configured retries, or LockError::Io for non-contention
filesystem failures (including failure to capture lock identity).
Sourcepub fn acquire_with(
target: impl AsRef<Path>,
options: &LockOptions,
) -> Result<Self, LockError>
pub fn acquire_with( target: impl AsRef<Path>, options: &LockOptions, ) -> Result<Self, LockError>
Acquire an exclusive lock with a custom policy.
§Errors
Returns LockError::Contended when another live holder owns the lock
after the configured retries, or LockError::Io for non-contention
filesystem failures (including failure to capture lock identity).
Sourcepub fn release(self) -> Result<(), LockError>
pub fn release(self) -> Result<(), LockError>
Explicitly release the lock. Equivalent to dropping the guard.
§Errors
Returns LockError::Io only when the lock directory is still owned by
this guard and remove_dir fails for a reason other than not found.
Ownership loss is treated as a successful no-op.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for LockGuard
impl !UnwindSafe for LockGuard
impl Freeze for LockGuard
impl Send for LockGuard
impl Sync for LockGuard
impl Unpin for LockGuard
impl UnsafeUnpin for LockGuard
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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