pub struct LockOptions {
pub attempts: u32,
pub retry_delay: Duration,
pub stale: Duration,
pub update: Duration,
pub lockfile_path: Option<PathBuf>,
}Expand description
Configurable acquisition and ownership policy.
Production callers use LockOptions::default. Focused tests shorten
attempts, retry_delay, stale, and update so they stay within the
10 × 20 ms production sleep budget without an injectable clock.
Fields§
§attempts: u32Maximum create attempts, including the first try. Must be ≥ 1.
retry_delay: DurationSleep between contention retries. Skipped when zero.
stale: DurationAge at which an existing lock directory may be reclaimed.
update: DurationHeartbeat interval for refreshing the held lock directory mtime.
When zero, no background refresh is started (the holder can still be
stolen after stale elapses).
lockfile_path: Option<PathBuf>Override for the lock directory path.
When None, the lock path is ${absolute_target}.lock. Trust storage
passes an explicit sibling such as trust.json.lock while locking the
parent directory.
Implementations§
Source§impl LockOptions
impl LockOptions
Sourcepub fn attempts(self, attempts: u32) -> Self
pub fn attempts(self, attempts: u32) -> Self
Set the maximum number of create attempts (including the first).
Sourcepub fn retry_delay(self, retry_delay: Duration) -> Self
pub fn retry_delay(self, retry_delay: Duration) -> Self
Set the delay between contention retries.
Sourcepub fn stale(self, stale: Duration) -> Self
pub fn stale(self, stale: Duration) -> Self
Set the stale threshold used when reclaiming an abandoned lock.
Sourcepub fn update(self, update: Duration) -> Self
pub fn update(self, update: Duration) -> Self
Set the mtime refresh interval while the lock is held.
Sourcepub fn lockfile_path(self, lockfile_path: impl Into<PathBuf>) -> Self
pub fn lockfile_path(self, lockfile_path: impl Into<PathBuf>) -> Self
Override the lock directory path.
Trait Implementations§
Source§impl Clone for LockOptions
impl Clone for LockOptions
Source§fn clone(&self) -> LockOptions
fn clone(&self) -> LockOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LockOptions
impl Debug for LockOptions
Source§impl Default for LockOptions
impl Default for LockOptions
impl Eq for LockOptions
Source§impl PartialEq for LockOptions
impl PartialEq for LockOptions
impl StructuralPartialEq for LockOptions
Auto Trait Implementations§
impl Freeze for LockOptions
impl RefUnwindSafe for LockOptions
impl Send for LockOptions
impl Sync for LockOptions
impl Unpin for LockOptions
impl UnsafeUnpin for LockOptions
impl UnwindSafe for LockOptions
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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