Skip to main content

SessionStore

Trait SessionStore 

Source
pub trait SessionStore:
    Send
    + Sync
    + Debug {
    // Required methods
    fn read_entries(
        &self,
        file_path: &Path,
    ) -> Result<Vec<SessionEntry>, SessionError>;
    fn append_entry(
        &self,
        file_path: &Path,
        entry: &SessionEntry,
    ) -> Result<(), SessionError>;
    fn replace_entries_atomically(
        &self,
        file_path: &Path,
        entries: &[SessionEntry],
    ) -> Result<(), SessionError>;
    fn read_last_entry_id(&self, file_path: &Path) -> Option<String>;
    fn scan_file(&self, file_path: &Path) -> Result<SessionInfo, SessionError>;
    fn read_bytes(&self, file_path: &Path) -> Result<Vec<u8>, SessionError>;
    fn file_extension(&self) -> &'static str;
}
Expand description

Trait abstracting session entry persistence.

Enables different storage formats (JSONL, compact text, segment chains) while keeping the Session and SessionManager types format-agnostic.

Required Methods§

Source

fn read_entries( &self, file_path: &Path, ) -> Result<Vec<SessionEntry>, SessionError>

Read all entries from a session file.

Source

fn append_entry( &self, file_path: &Path, entry: &SessionEntry, ) -> Result<(), SessionError>

Append a single entry to a session file.

Source

fn replace_entries_atomically( &self, file_path: &Path, entries: &[SessionEntry], ) -> Result<(), SessionError>

Replace a complete log using a temporary sibling file and atomic rename.

Used only by durable turn commits, where all entries for a successful turn must become visible together.

Source

fn read_last_entry_id(&self, file_path: &Path) -> Option<String>

Read the ID of the last entry in the file.

Source

fn scan_file(&self, file_path: &Path) -> Result<SessionInfo, SessionError>

Scan a session file for message count and last preview text.

Source

fn read_bytes(&self, file_path: &Path) -> Result<Vec<u8>, SessionError>

Read the session file as raw bytes.

Source

fn file_extension(&self) -> &'static str

The file extension for this store’s format (e.g., "jsonl").

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§