pub struct SessionStore { /* private fields */ }Expand description
Persists SessionSnapshot JSON files to disk under <data_dir>/sessions/.
By default, secret redaction is enabled so API keys and tokens are scrubbed from saved event text.
Implementations§
Source§impl SessionStore
impl SessionStore
Sourcepub fn with_redaction(data_dir: PathBuf, redact_secrets: bool) -> Self
pub fn with_redaction(data_dir: PathBuf, redact_secrets: bool) -> Self
Creates a new store with the given redaction setting.
Sourcepub fn create_id() -> SessionId
pub fn create_id() -> SessionId
Generates a new SessionId based on the current Unix timestamp in milliseconds.
Sourcepub fn save(&self, snapshot: &SessionSnapshot) -> Result<PathBuf>
pub fn save(&self, snapshot: &SessionSnapshot) -> Result<PathBuf>
Serializes and saves a snapshot to disk, creating the sessions directory if needed. Applies secret redaction unless disabled.
This is the blocking implementation used internally and in tests. Use
Self::save_async from async contexts to avoid blocking the Tokio
runtime.
Sourcepub async fn save_async(&self, snapshot: SessionSnapshot) -> Result<PathBuf>
pub async fn save_async(&self, snapshot: SessionSnapshot) -> Result<PathBuf>
Async wrapper around Self::save that runs the blocking filesystem
operations on the Tokio blocking thread pool.
Sourcepub fn list(&self) -> Vec<SessionSnapshot>
pub fn list(&self) -> Vec<SessionSnapshot>
Loads all saved sessions from disk, sorted by most recently updated first.
Sourcepub fn list_info(&self) -> Vec<SessionSnapshotInfo>
pub fn list_info(&self) -> Vec<SessionSnapshotInfo>
Loads only session metadata from disk, sorted by most recently updated first.
Sourcepub async fn list_async(&self) -> Vec<SessionSnapshot>
pub async fn list_async(&self) -> Vec<SessionSnapshot>
Async wrapper around Self::list that runs the blocking filesystem
operations on the Tokio blocking thread pool.
Sourcepub async fn list_info_async(&self) -> Vec<SessionSnapshotInfo>
pub async fn list_info_async(&self) -> Vec<SessionSnapshotInfo>
Async wrapper around Self::list_info that avoids blocking the async runtime.
Sourcepub fn load(&self, session_id: &str) -> Result<SessionSnapshot>
pub fn load(&self, session_id: &str) -> Result<SessionSnapshot>
Loads a single session by id. Returns an error if the file is missing or the snapshot version is newer than supported.
Sourcepub async fn load_async(&self, session_id: String) -> Result<SessionSnapshot>
pub async fn load_async(&self, session_id: String) -> Result<SessionSnapshot>
Async wrapper around Self::load that runs the blocking filesystem
operations on the Tokio blocking thread pool.
Sourcepub fn delete(&self, session_id: &str) -> Result<bool>
pub fn delete(&self, session_id: &str) -> Result<bool>
Deletes the session file. Returns true if the file existed and was removed.
Sourcepub fn rename(&self, session_id: &str, title: &str) -> Result<bool>
pub fn rename(&self, session_id: &str, title: &str) -> Result<bool>
Renames a saved session by updating its title field in the snapshot.
Returns true if the session existed and was updated.
Sourcepub async fn rename_async(
&self,
session_id: String,
title: String,
) -> Result<bool>
pub async fn rename_async( &self, session_id: String, title: String, ) -> Result<bool>
Async wrapper around Self::rename.
Sourcepub async fn delete_async(&self, session_id: String) -> Result<bool>
pub async fn delete_async(&self, session_id: String) -> Result<bool>
Async wrapper around Self::delete that runs the blocking filesystem
operations on the Tokio blocking thread pool.
Sourcepub fn save_memory(
&self,
project_dir: &Path,
memory: &ProjectMemory,
) -> Result<PathBuf>
pub fn save_memory( &self, project_dir: &Path, memory: &ProjectMemory, ) -> Result<PathBuf>
Persists project memory to <data_dir>/memory/<hash>.json.
Sourcepub async fn save_memory_async(
&self,
project_dir: PathBuf,
memory: ProjectMemory,
) -> Result<PathBuf>
pub async fn save_memory_async( &self, project_dir: PathBuf, memory: ProjectMemory, ) -> Result<PathBuf>
Async wrapper around Self::save_memory that runs the blocking
filesystem operations on the Tokio blocking thread pool.
Sourcepub fn load_memory(&self, project_dir: &Path) -> Option<ProjectMemory>
pub fn load_memory(&self, project_dir: &Path) -> Option<ProjectMemory>
Loads project memory from disk, returning None if no memory file exists.
Sourcepub async fn load_memory_async(
&self,
project_dir: PathBuf,
) -> Option<ProjectMemory>
pub async fn load_memory_async( &self, project_dir: PathBuf, ) -> Option<ProjectMemory>
Async wrapper around Self::load_memory that runs the blocking
filesystem operations on the Tokio blocking thread pool.
Sourcepub fn add_memory_entry(
&self,
project_dir: &Path,
session_id: &SessionId,
summary: String,
) -> Result<PathBuf>
pub fn add_memory_entry( &self, project_dir: &Path, session_id: &SessionId, summary: String, ) -> Result<PathBuf>
Appends a new memory entry for the project and persists it to disk.
Sourcepub async fn add_memory_entry_async(
&self,
project_dir: PathBuf,
session_id: String,
summary: String,
) -> Result<PathBuf>
pub async fn add_memory_entry_async( &self, project_dir: PathBuf, session_id: String, summary: String, ) -> Result<PathBuf>
Async wrapper around Self::add_memory_entry that runs the blocking
filesystem operations on the Tokio blocking thread pool.
Trait Implementations§
Source§impl Clone for SessionStore
impl Clone for SessionStore
Source§fn clone(&self) -> SessionStore
fn clone(&self) -> SessionStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more