pub struct FileLock { /* private fields */ }Expand description
A held lock. Dropping it releases the lock.
Implementations§
Source§impl FileLock
impl FileLock
Sourcepub async fn acquire(
file: &Path,
cancel: &CancellationToken,
) -> Result<FileLock, LockError>
pub async fn acquire( file: &Path, cancel: &CancellationToken, ) -> Result<FileLock, LockError>
Locks file, retrying with jittered backoff until the stale period has
passed. While held, the lock is kept fresh.
Sourcepub fn acquire_blocking(file: &Path) -> Result<FileLock, LockError>
pub fn acquire_blocking(file: &Path) -> Result<FileLock, LockError>
Locks file from synchronous code, as pi’s lockSync with its retries
for settings.json and trust.json: ten attempts 20 ms apart, then
LockError::Held. The lock is not kept fresh, so hold it only briefly.
Trait Implementations§
Auto Trait Implementations§
impl Forget for FileLock
impl Freeze for FileLock
impl RefUnwindSafe for FileLock
impl Send for FileLock
impl Sync for FileLock
impl Unpin for FileLock
impl UnsafeUnpin for FileLock
impl UnwindSafe for FileLock
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