Skip to main content

StateStore

Trait StateStore 

Source
pub trait StateStore: Send + Sync {
    // Required methods
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Value>, FaucetError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn put<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        value: &'life2 Value,
    ) -> Pin<Box<dyn Future<Output = Result<(), FaucetError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), FaucetError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn check<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _ctx: &'life1 CheckContext,
    ) -> Pin<Box<dyn Future<Output = Result<CheckReport, FaucetError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn supports_list(&self) -> bool { ... }
    fn list<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _prefix: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, FaucetError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn supports_compare_and_put(&self) -> bool { ... }
    fn compare_and_put<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        expected: Option<&'life2 Value>,
        value: &'life3 Value,
    ) -> Pin<Box<dyn Future<Output = Result<bool, FaucetError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
    fn supports_atomic_batch(&self) -> bool { ... }
    fn put_batch<'life0, 'life1, 'async_trait>(
        &'life0 self,
        entries: &'life1 [(String, Value)],
    ) -> Pin<Box<dyn Future<Output = Result<(), FaucetError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Persistent key/value store for replication bookmarks and pipeline checkpoints.

Implementations must be safe to call from multiple tasks at once. The trait is intentionally minimal — three operations cover every bookmark flow the pipeline orchestrator needs.

Required Methods§

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Value>, FaucetError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Return the value stored under key, or None if no entry exists.

Source

fn put<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 str, value: &'life2 Value, ) -> Pin<Box<dyn Future<Output = Result<(), FaucetError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Store value under key, replacing any previous entry.

Implementations should make the update durable before returning so a crash immediately after put does not lose the bookmark.

Source

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), FaucetError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove the entry for key. A missing key is not an error.

Provided Methods§

Source

fn check<'life0, 'life1, 'async_trait>( &'life0 self, _ctx: &'life1 CheckContext, ) -> Pin<Box<dyn Future<Output = Result<CheckReport, FaucetError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Run a fast, non-mutating preflight probe (used by faucet doctor).

The default returns CheckReport::not_implemented. Built-in stores override this with a reachability + sentinel get/put/delete probe that leaves no residue.

Source

fn supports_list(&self) -> bool

Whether list can enumerate keys. Every built-in store can; the default is false so a third-party store keeps compiling.

Source

fn list<'life0, 'life1, 'async_trait>( &'life0 self, _prefix: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, FaucetError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Every stored key that starts with prefix, sorted ascending.

Used to enumerate a pipeline’s namespace ({name}::…) for faucet state show|export. The default returns a typed error.

Source

fn supports_compare_and_put(&self) -> bool

Whether compare_and_put is atomic.

Source

fn compare_and_put<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, key: &'life1 str, expected: Option<&'life2 Value>, value: &'life3 Value, ) -> Pin<Box<dyn Future<Output = Result<bool, FaucetError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Store value under key only when the entry still equals expected (None = no entry). Returns whether it was written. Two holders of one value (a rotated credential, say) use it so the second writer does not clobber the first.

The default reads, compares and writes — not atomic across processes; stores that can do better override it and supports_compare_and_put.

Source

fn supports_atomic_batch(&self) -> bool

Whether put_batch commits all-or-nothing.

Source

fn put_batch<'life0, 'life1, 'async_trait>( &'life0 self, entries: &'life1 [(String, Value)], ) -> Pin<Box<dyn Future<Output = Result<(), FaucetError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store every entry. When supports_atomic_batch is true either all entries land or none do; the default writes them one by one, so an error can leave a prefix of entries written.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§