pub struct LockRegistryHandle(pub Arc<LockRegistry>);Expand description
Arc<LockRegistry> wrapped for Tauri’s State system.
Tuple Fields§
§0: Arc<LockRegistry>Implementations§
Source§impl LockRegistryHandle
impl LockRegistryHandle
pub fn new(registry: LockRegistry) -> Self
pub fn inner(&self) -> &LockRegistry
Methods from Deref<Target = LockRegistry>§
Sourcepub fn acquire(
&self,
scope: LockScope,
op_name: impl Into<String>,
ttl_secs: u64,
now: i64,
) -> Result<LockId, AppError>
pub fn acquire( &self, scope: LockScope, op_name: impl Into<String>, ttl_secs: u64, now: i64, ) -> Result<LockId, AppError>
Acquire a lock for scope / op_name with ttl_secs TTL.
Returns the new LockId on success. Returns AppError::Locked when
any existing lock has an intersecting scope.
The caller is responsible for emitting lock:acquired via
lifecycle::emit_acquired.
Sourcepub fn heartbeat(&self, lock_id: &LockId, now: i64) -> Result<(), AppError>
pub fn heartbeat(&self, lock_id: &LockId, now: i64) -> Result<(), AppError>
Extend the heartbeat for lock_id.
Returns AppError::NotFound if the lock does not exist.
Sourcepub fn release(&self, lock_id: &LockId) -> Result<ResourceLock, AppError>
pub fn release(&self, lock_id: &LockId) -> Result<ResourceLock, AppError>
Release a lock explicitly.
Returns AppError::NotFound if the lock does not exist.
The returned ResourceLock carries the scope needed for the event.
Sourcepub fn list(&self, scope_filter: Option<&LockScope>) -> Vec<ResourceLock>
pub fn list(&self, scope_filter: Option<&LockScope>) -> Vec<ResourceLock>
Return all active locks, optionally filtered to those whose scope
intersects scope_filter.
Sourcepub fn release_stale(&self, now: i64) -> Vec<ResourceLock>
pub fn release_stale(&self, now: i64) -> Vec<ResourceLock>
Release all locks whose TTL has expired relative to now.
Returns the released locks so the caller can emit events.
Sourcepub fn startup_cleanup(&self) -> Vec<ResourceLock>
pub fn startup_cleanup(&self) -> Vec<ResourceLock>
Remove all locks regardless of TTL.
Called once at app start to clear any locks left over from a prior crash
or abnormal exit. Returns the removed locks so the caller can emit
lock:released { reason: StartupCleanup } for each.
Trait Implementations§
Source§impl Clone for LockRegistryHandle
impl Clone for LockRegistryHandle
Source§fn clone(&self) -> LockRegistryHandle
fn clone(&self) -> LockRegistryHandle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for LockRegistryHandle
impl Default for LockRegistryHandle
Source§impl Deref for LockRegistryHandle
impl Deref for LockRegistryHandle
Source§type Target = LockRegistry
type Target = LockRegistry
Source§fn deref(&self) -> &LockRegistry
fn deref(&self) -> &LockRegistry
Auto Trait Implementations§
impl Freeze for LockRegistryHandle
impl RefUnwindSafe for LockRegistryHandle
impl Send for LockRegistryHandle
impl Sync for LockRegistryHandle
impl Unpin for LockRegistryHandle
impl UnsafeUnpin for LockRegistryHandle
impl UnwindSafe for LockRegistryHandle
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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