pub struct CacheLock { /* private fields */ }Expand description
The exclusive lock on a cache, held until it is released or dropped.
Implementations§
Source§impl CacheLock
impl CacheLock
Sourcepub fn acquire(
cache_dir: &Path,
details: &LockDetails,
on_wait: impl FnMut(&LockDetails),
) -> Result<Self, LockError>
pub fn acquire( cache_dir: &Path, details: &LockDetails, on_wait: impl FnMut(&LockDetails), ) -> Result<Self, LockError>
Takes the lock of the cache in cache_dir, creating the directory if needed,
and writes details into the lock file.
While another process holds the lock, this waits, and calls on_wait with the
holder’s details at once, and again whenever a different process takes the
lock.
§Errors
A LockError when the directory or the lock file cannot be created, locked,
or written.
Sourcepub fn acquire_with(
cache_dir: &Path,
details: &LockDetails,
options: LockOptions,
on_wait: impl FnMut(&LockDetails),
) -> Result<Self, LockError>
pub fn acquire_with( cache_dir: &Path, details: &LockDetails, options: LockOptions, on_wait: impl FnMut(&LockDetails), ) -> Result<Self, LockError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CacheLock
impl RefUnwindSafe for CacheLock
impl Send for CacheLock
impl Sync for CacheLock
impl Unpin for CacheLock
impl UnsafeUnpin for CacheLock
impl UnwindSafe for CacheLock
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
Mutably borrows from an owned value. Read more