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§
Sourcefn read_entries(
&self,
file_path: &Path,
) -> Result<Vec<SessionEntry>, SessionError>
fn read_entries( &self, file_path: &Path, ) -> Result<Vec<SessionEntry>, SessionError>
Read all entries from a session file.
Sourcefn append_entry(
&self,
file_path: &Path,
entry: &SessionEntry,
) -> Result<(), SessionError>
fn append_entry( &self, file_path: &Path, entry: &SessionEntry, ) -> Result<(), SessionError>
Append a single entry to a session file.
Sourcefn replace_entries_atomically(
&self,
file_path: &Path,
entries: &[SessionEntry],
) -> Result<(), SessionError>
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.
Sourcefn read_last_entry_id(&self, file_path: &Path) -> Option<String>
fn read_last_entry_id(&self, file_path: &Path) -> Option<String>
Read the ID of the last entry in the file.
Sourcefn scan_file(&self, file_path: &Path) -> Result<SessionInfo, SessionError>
fn scan_file(&self, file_path: &Path) -> Result<SessionInfo, SessionError>
Scan a session file for message count and last preview text.
Sourcefn read_bytes(&self, file_path: &Path) -> Result<Vec<u8>, SessionError>
fn read_bytes(&self, file_path: &Path) -> Result<Vec<u8>, SessionError>
Read the session file as raw bytes.
Sourcefn file_extension(&self) -> &'static str
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".