Skip to main content

SessionStore

Trait SessionStore 

Source
pub trait SessionStore: Send + Sync {
    // Required methods
    fn create(&self, title: Option<String>) -> Result<Session, Error>;
    fn get(&self, id: Uuid) -> Result<Option<Session>, Error>;
    fn list(&self) -> Result<Vec<Session>, Error>;
    fn delete(&self, id: Uuid) -> Result<bool, Error>;
    fn add_message(
        &self,
        id: Uuid,
        message: SessionMessage,
    ) -> Result<(), Error>;

    // Provided methods
    fn create_with_user(
        &self,
        title: Option<String>,
        user_id: &str,
        tenant_id: &str,
    ) -> Result<Session, Error> { ... }
    fn list_for_tenant(&self, tenant_id: &str) -> Result<Vec<Session>, Error> { ... }
}
Expand description

Trait for session persistence.

Required Methods§

Source

fn create(&self, title: Option<String>) -> Result<Session, Error>

Create a new session with an optional title.

Source

fn get(&self, id: Uuid) -> Result<Option<Session>, Error>

Get a session by ID. Returns None if not found.

Source

fn list(&self) -> Result<Vec<Session>, Error>

List all sessions (most recent first).

Source

fn delete(&self, id: Uuid) -> Result<bool, Error>

Delete a session. Returns true if found and deleted.

Source

fn add_message(&self, id: Uuid, message: SessionMessage) -> Result<(), Error>

Append a message to an existing session.

Provided Methods§

Source

fn create_with_user( &self, title: Option<String>, user_id: &str, tenant_id: &str, ) -> Result<Session, Error>

Create a session with user/tenant context for multi-tenant isolation. Default: delegates to create() and patches user/tenant fields.

Source

fn list_for_tenant(&self, tenant_id: &str) -> Result<Vec<Session>, Error>

List sessions scoped to a tenant (most recent first). Default: calls list() and filters in-memory.

Implementors§