Skip to main content

SessionStore

Trait SessionStore 

Source
pub trait SessionStore: Send + Sync {
    // Required methods
    fn create<'life0, 'async_trait>(
        &'life0 self,
        meta: SessionMeta,
    ) -> Pin<Box<dyn Future<Output = Result<String, AgentError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn append<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_id: &'life1 str,
        entry: SessionEntry,
    ) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn load<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<SessionEntry>, AgentError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<SessionMeta>, AgentError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Append-only storage for session logs.

The trait surface is deliberately append-only (invariant 2 of the module docs): implementations must not expose delete, update, or overwrite operations.

Required Methods§

Source

fn create<'life0, 'async_trait>( &'life0 self, meta: SessionMeta, ) -> Pin<Box<dyn Future<Output = Result<String, AgentError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Creates a new session from its header and returns the session id.

Errors if a session with meta.id already exists.

Source

fn append<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, entry: SessionEntry, ) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Appends one entry to an existing session.

Callers must append only finalized messages (message.streaming == false, invariant 1 of the module docs); partial streaming messages belong in the caller’s memory, not in the store.

Source

fn load<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<SessionEntry>, AgentError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads all entries of a session in append order.

Source

fn list<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<SessionMeta>, AgentError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Lists the headers of all sessions in the store.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§