pub struct DynamoStateStore { /* private fields */ }Expand description
DynamoDB-backed state store
Implementations§
Source§impl DynamoStateStore
impl DynamoStateStore
Sourcepub async fn new() -> Result<Self, StateError>
pub async fn new() -> Result<Self, StateError>
Create new state store with default config
Sourcepub async fn with_config(config: DynamoConfig) -> Result<Self, StateError>
pub async fn with_config(config: DynamoConfig) -> Result<Self, StateError>
Create with custom config
Sourcepub async fn lookup_user_by_card(
&self,
fingerprint: &str,
) -> Result<Option<CardMapping>, StateError>
pub async fn lookup_user_by_card( &self, fingerprint: &str, ) -> Result<Option<CardMapping>, StateError>
Look up user by card fingerprint This is the “glue” that connects POS webhooks to user vaults
Sourcepub async fn link_card(
&self,
fingerprint: &str,
user_pubkey: &str,
card_last4: &str,
) -> Result<(), StateError>
pub async fn link_card( &self, fingerprint: &str, user_pubkey: &str, card_last4: &str, ) -> Result<(), StateError>
Link a card fingerprint to a user
Sourcepub async fn unlink_card(&self, fingerprint: &str) -> Result<(), StateError>
pub async fn unlink_card(&self, fingerprint: &str) -> Result<(), StateError>
Unlink a card fingerprint
Sourcepub async fn get_user_cards(
&self,
user_pubkey: &str,
) -> Result<Vec<CardMapping>, StateError>
pub async fn get_user_cards( &self, user_pubkey: &str, ) -> Result<Vec<CardMapping>, StateError>
Get all cards linked to a user
Sourcepub async fn is_transaction_processed(
&self,
txn_id: &str,
) -> Result<bool, StateError>
pub async fn is_transaction_processed( &self, txn_id: &str, ) -> Result<bool, StateError>
Check if a transaction has already been processed
Sourcepub async fn mark_transaction_processed(
&self,
txn_id: &str,
user_pubkey: &str,
cred_amount: u64,
) -> Result<(), StateError>
pub async fn mark_transaction_processed( &self, txn_id: &str, user_pubkey: &str, cred_amount: u64, ) -> Result<(), StateError>
Mark a transaction as processed
Sourcepub async fn store_session_key(
&self,
user_pubkey: &str,
session: &SessionKeyData,
) -> Result<(), StateError>
pub async fn store_session_key( &self, user_pubkey: &str, session: &SessionKeyData, ) -> Result<(), StateError>
Store a session key with TTL
Sourcepub async fn get_session_key(
&self,
user_pubkey: &str,
) -> Result<Option<SessionKeyData>, StateError>
pub async fn get_session_key( &self, user_pubkey: &str, ) -> Result<Option<SessionKeyData>, StateError>
Get active session key for user
Sourcepub async fn invalidate_session(
&self,
user_pubkey: &str,
) -> Result<(), StateError>
pub async fn invalidate_session( &self, user_pubkey: &str, ) -> Result<(), StateError>
Invalidate session key
Sourcepub async fn add_pending_capture(
&self,
user_pubkey: &str,
capture: &PendingCapture,
) -> Result<(), StateError>
pub async fn add_pending_capture( &self, user_pubkey: &str, capture: &PendingCapture, ) -> Result<(), StateError>
Add a pending capture (limited to max_pending_captures per user)
Sourcepub async fn get_pending_captures(
&self,
user_pubkey: &str,
) -> Result<Vec<PendingCapture>, StateError>
pub async fn get_pending_captures( &self, user_pubkey: &str, ) -> Result<Vec<PendingCapture>, StateError>
Get all pending captures for user
Sourcepub async fn remove_pending_capture(
&self,
user_pubkey: &str,
timestamp: i64,
) -> Result<(), StateError>
pub async fn remove_pending_capture( &self, user_pubkey: &str, timestamp: i64, ) -> Result<(), StateError>
Remove a pending capture (after it’s been processed)
Sourcepub async fn cache_current_merchant(
&self,
user_pubkey: &str,
merchant_id: &str,
) -> Result<(), StateError>
pub async fn cache_current_merchant( &self, user_pubkey: &str, merchant_id: &str, ) -> Result<(), StateError>
Cache current merchant for user (geofence)
Sourcepub async fn get_current_merchant(
&self,
user_pubkey: &str,
) -> Result<Option<String>, StateError>
pub async fn get_current_merchant( &self, user_pubkey: &str, ) -> Result<Option<String>, StateError>
Get cached merchant location
Sourcepub async fn clear_current_merchant(
&self,
user_pubkey: &str,
) -> Result<(), StateError>
pub async fn clear_current_merchant( &self, user_pubkey: &str, ) -> Result<(), StateError>
Clear cached merchant location
Source§impl DynamoStateStore
impl DynamoStateStore
Sourcepub async fn context_fetch_async(
&self,
user_pubkey: &str,
) -> Result<UserContext, StateError>
pub async fn context_fetch_async( &self, user_pubkey: &str, ) -> Result<UserContext, StateError>
Async context fetch
Sourcepub async fn context_push_async(
&self,
context: UserContext,
) -> Result<(), StateError>
pub async fn context_push_async( &self, context: UserContext, ) -> Result<(), StateError>
Async context push with optimistic locking
Sourcepub async fn context_patch_async(
&self,
user_pubkey: &str,
path: &str,
value: Value,
) -> Result<(), StateError>
pub async fn context_patch_async( &self, user_pubkey: &str, path: &str, value: Value, ) -> Result<(), StateError>
Async context patch
Sourcepub async fn push_event_async(
&self,
user_pubkey: &str,
event: ContextEvent,
) -> Result<(), StateError>
pub async fn push_event_async( &self, user_pubkey: &str, event: ContextEvent, ) -> Result<(), StateError>
Async push event
Trait Implementations§
Source§impl StateStore for DynamoStateStore
impl StateStore for DynamoStateStore
Source§fn context_fetch(&self, user_pubkey: &str) -> Result<UserContext, StateError>
fn context_fetch(&self, user_pubkey: &str) -> Result<UserContext, StateError>
Source§fn context_push(&self, context: UserContext) -> Result<(), StateError>
fn context_push(&self, context: UserContext) -> Result<(), StateError>
Source§fn context_batch_fetch(
&self,
user_pubkeys: &[String],
) -> Result<Vec<UserContext>, StateError>
fn context_batch_fetch( &self, user_pubkeys: &[String], ) -> Result<Vec<UserContext>, StateError>
Source§fn context_patch(
&self,
user_pubkey: &str,
path: &str,
value: Value,
) -> Result<(), StateError>
fn context_patch( &self, user_pubkey: &str, path: &str, value: Value, ) -> Result<(), StateError>
Source§fn push_event(
&self,
user_pubkey: &str,
event: ContextEvent,
) -> Result<(), StateError>
fn push_event( &self, user_pubkey: &str, event: ContextEvent, ) -> Result<(), StateError>
Source§fn get_or_init(&self, user_pubkey: &str) -> Result<UserContext, StateError>
fn get_or_init(&self, user_pubkey: &str) -> Result<UserContext, StateError>
Auto Trait Implementations§
impl Freeze for DynamoStateStore
impl !RefUnwindSafe for DynamoStateStore
impl Send for DynamoStateStore
impl Sync for DynamoStateStore
impl Unpin for DynamoStateStore
impl UnsafeUnpin for DynamoStateStore
impl !UnwindSafe for DynamoStateStore
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more