Skip to main content

LockStore

Trait LockStore 

Source
pub trait LockStore: Send + Sync {
    // Required methods
    fn save(
        &self,
        resource: &str,
        token: &str,
        ttl: Option<Duration>,
    ) -> Result<(), LockError>;
    fn delete(&self, resource: &str, token: &str) -> Result<(), LockError>;
    fn exists(&self, resource: &str, token: &str) -> Result<bool, LockError>;
    fn put_off_expiration(
        &self,
        resource: &str,
        token: &str,
        ttl: Option<Duration>,
    ) -> Result<(), LockError>;
}
Expand description

Low-level lock persistence (Symfony PersistingStoreInterface analogue).

Required Methods§

Source

fn save( &self, resource: &str, token: &str, ttl: Option<Duration>, ) -> Result<(), LockError>

Persists ownership for resource under token.

When ttl is Some, ownership expires after that duration. None means no expiry. Same-token re-save refreshes ownership. Another token yields LockError::Conflict.

§Errors

Returns LockError on invalid resource, conflict, or store failure.

Source

fn delete(&self, resource: &str, token: &str) -> Result<(), LockError>

Drops ownership when token matches (idempotent when missing or expired).

§Errors

Returns LockError on store failure.

Source

fn exists(&self, resource: &str, token: &str) -> Result<bool, LockError>

True when token currently owns resource and the entry has not expired.

§Errors

Returns LockError on store failure.

Source

fn put_off_expiration( &self, resource: &str, token: &str, ttl: Option<Duration>, ) -> Result<(), LockError>

Extends TTL for a held lock. ttl: None clears expiry (hold forever).

§Errors

Returns LockError::NotHeld when this token does not own the resource.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§