pub trait StateStore {
// Required methods
fn context_fetch(
&self,
user_pubkey: &str,
) -> Result<UserContext, StateError>;
fn context_push(&self, context: UserContext) -> Result<(), StateError>;
fn context_batch_fetch(
&self,
user_pubkeys: &[String],
) -> Result<Vec<UserContext>, StateError>;
fn context_patch(
&self,
user_pubkey: &str,
path: &str,
value: Value,
) -> Result<(), StateError>;
fn push_event(
&self,
user_pubkey: &str,
event: ContextEvent,
) -> Result<(), StateError>;
fn get_or_init(&self, user_pubkey: &str) -> Result<UserContext, StateError>;
}Expand description
State storage backend trait Can be backed by DynamoDB, Redis, or Solana account data
Required Methods§
Sourcefn context_fetch(&self, user_pubkey: &str) -> Result<UserContext, StateError>
fn context_fetch(&self, user_pubkey: &str) -> Result<UserContext, StateError>
Fetch user context (<100ms target)
Sourcefn context_push(&self, context: UserContext) -> Result<(), StateError>
fn context_push(&self, context: UserContext) -> Result<(), StateError>
Push updated context (with optimistic locking)
Sourcefn context_batch_fetch(
&self,
user_pubkeys: &[String],
) -> Result<Vec<UserContext>, StateError>
fn context_batch_fetch( &self, user_pubkeys: &[String], ) -> Result<Vec<UserContext>, StateError>
Fetch multiple users (for batch operations)
Sourcefn 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>
Update specific field without full fetch/push
Sourcefn push_event(
&self,
user_pubkey: &str,
event: ContextEvent,
) -> Result<(), StateError>
fn push_event( &self, user_pubkey: &str, event: ContextEvent, ) -> Result<(), StateError>
Add event to recent events (ring buffer)
Sourcefn get_or_init(&self, user_pubkey: &str) -> Result<UserContext, StateError>
fn get_or_init(&self, user_pubkey: &str) -> Result<UserContext, StateError>
Get or initialize context for new user