pub trait TransactionStore: Send + Sync {
// Required methods
fn create<'life0, 'async_trait>(
&'life0 self,
record: TransactionRecord,
) -> Pin<Box<dyn Future<Output = Result<(), TransactionError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<TransactionRecord>, TransactionError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn update<'life0, 'async_trait>(
&'life0 self,
record: TransactionRecord,
) -> Pin<Box<dyn Future<Output = Result<(), TransactionError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), TransactionError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn list_by_user<'life0, 'life1, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<TransactionRecord>, TransactionError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn cleanup_expired<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize, TransactionError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Trait for pluggable transaction storage backends
Implementations might be:
- In-memory (HashMap)
- PostgreSQL
- Redis
- DynamoDB
- Any custom storage system
Required Methods§
Sourcefn create<'life0, 'async_trait>(
&'life0 self,
record: TransactionRecord,
) -> Pin<Box<dyn Future<Output = Result<(), TransactionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create<'life0, 'async_trait>(
&'life0 self,
record: TransactionRecord,
) -> Pin<Box<dyn Future<Output = Result<(), TransactionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Create a new transaction
Sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<TransactionRecord>, TransactionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<TransactionRecord>, TransactionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a transaction by ID
Sourcefn update<'life0, 'async_trait>(
&'life0 self,
record: TransactionRecord,
) -> Pin<Box<dyn Future<Output = Result<(), TransactionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn update<'life0, 'async_trait>(
&'life0 self,
record: TransactionRecord,
) -> Pin<Box<dyn Future<Output = Result<(), TransactionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Update an existing transaction
Sourcefn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), TransactionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), TransactionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete a transaction
Sourcefn list_by_user<'life0, 'life1, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<TransactionRecord>, TransactionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_by_user<'life0, 'life1, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<TransactionRecord>, TransactionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
List transactions by user_id (for admin/debugging)
Sourcefn cleanup_expired<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize, TransactionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn cleanup_expired<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize, TransactionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Cleanup expired transactions (for background job)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".