pub trait ConfirmationStore: Send + Sync {
// Required methods
fn request_confirmation<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
payload: Value,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn confirm<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn reject<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn list_pending<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<PendingActionInfo>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Store for managing pending confirmation actions.
Stores type-erased serde_json::Value payloads keyed by a string.
Each entry has a TTL; when it expires, a ConfirmationExpired event is
dispatched via ferro_events::dispatch_sync.
§Example
use ferro_ai::{InMemoryConfirmationStore, ConfirmationStore};
use std::time::Duration;
let store = InMemoryConfirmationStore::new(Duration::from_secs(60));
let payload = serde_json::json!({"action": "delete_user", "user_id": 42});
store.request_confirmation("confirm-delete-42", payload, Duration::from_secs(60)).await?;
let confirmed = store.confirm("confirm-delete-42").await?;
// confirmed = Some(serde_json::Value)Required Methods§
Sourcefn request_confirmation<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
payload: Value,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn request_confirmation<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
payload: Value,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Store a payload under the given key, replacing any existing entry.
Starts a TTL timer. When the timer expires, the entry is removed and
a ConfirmationExpired event is dispatched.
Sourcefn confirm<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn confirm<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Confirm the action identified by key.
Removes the entry and aborts its TTL timer.
Returns the stored payload, or None if the key does not exist.
Sourcefn reject<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn reject<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Reject the action identified by key.
Removes the entry and aborts its TTL timer without dispatching an expiry event.
Returns true if the entry existed, false if it was not found.
Sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve the stored payload without removing the entry.
Returns None if the key does not exist or has already expired.
Sourcefn list_pending<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<PendingActionInfo>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_pending<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<PendingActionInfo>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
List all pending (not yet confirmed, rejected, or expired) entries.