pub trait EventStore: Send + Sync {
// Required methods
fn append<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
turn: usize,
envelope: AgentEventEnvelope,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn finish_turn<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
turn: usize,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_turn<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
turn: usize,
) -> Pin<Box<dyn Future<Output = Result<Option<StoredTurnEvents>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_turns<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
) -> Pin<Box<dyn Future<Output = Result<Vec<StoredTurnEvents>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn clear<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn get_events<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
) -> Pin<Box<dyn Future<Output = Result<Vec<AgentEventEnvelope>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn event_count<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn get_events_since<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
offset: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<AgentEventEnvelope>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Trait for storing and retrieving turn-scoped event streams.
Event writes are split into two phases:
appendrecords individual envelopesfinish_turnmarks the authoritative close barrier
Required Methods§
Sourcefn append<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
turn: usize,
envelope: AgentEventEnvelope,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn append<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
turn: usize,
envelope: AgentEventEnvelope,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Append an event envelope for the given thread and turn.
§Errors
Returns an error if the event cannot be persisted.
Sourcefn finish_turn<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
turn: usize,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn finish_turn<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
turn: usize,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Mark the given turn as finished and flush any buffered writes.
§Errors
Returns an error if the store cannot durably close the turn.
Sourcefn get_turn<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
turn: usize,
) -> Pin<Box<dyn Future<Output = Result<Option<StoredTurnEvents>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_turn<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
turn: usize,
) -> Pin<Box<dyn Future<Output = Result<Option<StoredTurnEvents>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve the stored data for a single turn.
§Errors
Returns an error if the turn cannot be retrieved.
Sourcefn get_turns<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
) -> Pin<Box<dyn Future<Output = Result<Vec<StoredTurnEvents>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_turns<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
) -> Pin<Box<dyn Future<Output = Result<Vec<StoredTurnEvents>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve all stored turns for the given thread in ascending turn order.
§Errors
Returns an error if the thread history cannot be retrieved.
Provided Methods§
Sourcefn get_events<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
) -> Pin<Box<dyn Future<Output = Result<Vec<AgentEventEnvelope>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_events<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
) -> Pin<Box<dyn Future<Output = Result<Vec<AgentEventEnvelope>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve all event envelopes for the given thread across every stored turn.
§Errors
Returns an error if the thread history cannot be retrieved.
Sourcefn event_count<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn event_count<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Count the stored events for thread_id without materializing them.
The default falls back to the length of
get_events (which clones the whole history);
stores that can answer cheaply should override this. Callers that only
need a baseline count — e.g. to read just the new events after a turn —
should prefer this over get_events(..).len().
§Errors
Returns an error if the count cannot be retrieved.
Sourcefn get_events_since<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
offset: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<AgentEventEnvelope>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_events_since<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId,
offset: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<AgentEventEnvelope>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve event envelopes for thread_id from offset onward, in overall
append order, skipping the earlier ones.
Lets incremental readers avoid re-cloning the whole history each call.
The default slices get_events; stores with a
cheaper access path should override.
§Errors
Returns an error if the events cannot be retrieved.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".