pub trait ResponseStorage: Send + Sync {
// Required methods
fn store_response<'life0, 'async_trait>(
&'life0 self,
response: StoredResponse,
) -> Pin<Box<dyn Future<Output = Result<ResponseId, ResponseStorageError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_response<'life0, 'life1, 'async_trait>(
&'life0 self,
response_id: &'life1 ResponseId,
) -> Pin<Box<dyn Future<Output = Result<Option<StoredResponse>, ResponseStorageError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete_response<'life0, 'life1, 'async_trait>(
&'life0 self,
response_id: &'life1 ResponseId,
) -> Pin<Box<dyn Future<Output = Result<(), ResponseStorageError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn list_identifier_responses<'life0, 'life1, 'async_trait>(
&'life0 self,
identifier: &'life1 str,
limit: Option<usize>,
) -> Pin<Box<dyn Future<Output = Result<Vec<StoredResponse>, ResponseStorageError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete_identifier_responses<'life0, 'life1, 'async_trait>(
&'life0 self,
identifier: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<usize, ResponseStorageError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn get_response_chain<'life0, 'life1, 'async_trait>(
&'life0 self,
response_id: &'life1 ResponseId,
max_depth: Option<usize>,
) -> Pin<Box<dyn Future<Output = Result<ResponseChain, ResponseStorageError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Trait for response storage
Required Methods§
Sourcefn store_response<'life0, 'async_trait>(
&'life0 self,
response: StoredResponse,
) -> Pin<Box<dyn Future<Output = Result<ResponseId, ResponseStorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn store_response<'life0, 'async_trait>(
&'life0 self,
response: StoredResponse,
) -> Pin<Box<dyn Future<Output = Result<ResponseId, ResponseStorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Store a new response
Sourcefn get_response<'life0, 'life1, 'async_trait>(
&'life0 self,
response_id: &'life1 ResponseId,
) -> Pin<Box<dyn Future<Output = Result<Option<StoredResponse>, ResponseStorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_response<'life0, 'life1, 'async_trait>(
&'life0 self,
response_id: &'life1 ResponseId,
) -> Pin<Box<dyn Future<Output = Result<Option<StoredResponse>, ResponseStorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a response by ID
Sourcefn delete_response<'life0, 'life1, 'async_trait>(
&'life0 self,
response_id: &'life1 ResponseId,
) -> Pin<Box<dyn Future<Output = Result<(), ResponseStorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_response<'life0, 'life1, 'async_trait>(
&'life0 self,
response_id: &'life1 ResponseId,
) -> Pin<Box<dyn Future<Output = Result<(), ResponseStorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete a response
Sourcefn list_identifier_responses<'life0, 'life1, 'async_trait>(
&'life0 self,
identifier: &'life1 str,
limit: Option<usize>,
) -> Pin<Box<dyn Future<Output = Result<Vec<StoredResponse>, ResponseStorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_identifier_responses<'life0, 'life1, 'async_trait>(
&'life0 self,
identifier: &'life1 str,
limit: Option<usize>,
) -> Pin<Box<dyn Future<Output = Result<Vec<StoredResponse>, ResponseStorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
List recent responses for a safety identifier
Sourcefn delete_identifier_responses<'life0, 'life1, 'async_trait>(
&'life0 self,
identifier: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<usize, ResponseStorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_identifier_responses<'life0, 'life1, 'async_trait>(
&'life0 self,
identifier: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<usize, ResponseStorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete all responses for a safety identifier
Provided Methods§
Sourcefn get_response_chain<'life0, 'life1, 'async_trait>(
&'life0 self,
response_id: &'life1 ResponseId,
max_depth: Option<usize>,
) -> Pin<Box<dyn Future<Output = Result<ResponseChain, ResponseStorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_response_chain<'life0, 'life1, 'async_trait>(
&'life0 self,
response_id: &'life1 ResponseId,
max_depth: Option<usize>,
) -> Pin<Box<dyn Future<Output = Result<ResponseChain, ResponseStorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get the chain of responses leading to a given response.
Walks previous_response_id links from the given response backwards,
collecting up to max_depth responses (or unlimited if None).
Returns responses in chronological order (oldest first).
The default implementation calls self.get_response() in a loop with
cycle detection to prevent infinite loops from self-referencing chains.
Backends that can walk the chain more efficiently (e.g. with a single
lock or a recursive SQL query) should override this.