pub struct SessionArchive { /* private fields */ }Expand description
Local archive of every CodeSwarm session for one machine.
Constructed from an explicit root; this type performs no environment lookups, so the root CLI stays in control of storage locations.
Implementations§
Source§impl SessionArchive
impl SessionArchive
pub fn open(root: impl Into<PathBuf>) -> Self
pub fn root(&self) -> &Path
Sourcepub fn create(
&self,
request: CreateSession,
) -> Result<ArchiveEntry, PersistenceError>
pub fn create( &self, request: CreateSession, ) -> Result<ArchiveEntry, PersistenceError>
Create a new session with a fresh, immutable id. An existing archived conversation is never overwritten: the id is allocated exclusively.
Sourcepub fn create_exact(
&self,
id: &str,
request: CreateSession,
) -> Result<ArchiveEntry, PersistenceError>
pub fn create_exact( &self, id: &str, request: CreateSession, ) -> Result<ArchiveEntry, PersistenceError>
Create a session with an explicit id. Fails when the id is invalid or already archived, so archived conversations can never be overwritten.
Sourcepub fn list(&self, cwd: &Path) -> Result<SessionListing, PersistenceError>
pub fn list(&self, cwd: &Path) -> Result<SessionListing, PersistenceError>
List every archived session whose canonical project directory matches
cwd. Failures are always reported: corrupt metadata cannot be
attributed to a project, so it is surfaced for every listing.
Sourcepub fn list_all(&self) -> Result<SessionListing, PersistenceError>
pub fn list_all(&self) -> Result<SessionListing, PersistenceError>
List every archived session, newest activity first. Failures are sorted by session ID independently of filesystem enumeration order.
Sourcepub fn load(&self, id: &str) -> Result<ArchivedSession, PersistenceError>
pub fn load(&self, id: &str) -> Result<ArchivedSession, PersistenceError>
Load one archived session: entry, provider metadata, and ordered events. Missing sessions and unreadable metadata are reported with distinct errors; damaged journals still return every valid event.
Sourcepub fn append(
&self,
id: &str,
event: &ArchiveEvent,
) -> Result<(), PersistenceError>
pub fn append( &self, id: &str, event: &ArchiveEvent, ) -> Result<(), PersistenceError>
Append one journal record synchronously and force it to stable
storage. Runtime streaming should prefer Self::buffered.
pub fn append_human( &self, id: &str, text: impl Into<String>, direct: bool, ) -> Result<(), PersistenceError>
pub fn append_agent( &self, id: &str, event: &AgentEvent, ) -> Result<(), PersistenceError>
Sourcepub fn update_metadata<F>(
&self,
id: &str,
apply: F,
) -> Result<(), PersistenceError>where
F: FnOnce(&mut SessionMetadata),
pub fn update_metadata<F>(
&self,
id: &str,
apply: F,
) -> Result<(), PersistenceError>where
F: FnOnce(&mut SessionMetadata),
Edit provider metadata in place, preserving unknown keys.
Sourcepub fn update_entry<F>(
&self,
id: &str,
apply: F,
) -> Result<(), PersistenceError>where
F: FnOnce(&mut ArchiveEntry),
pub fn update_entry<F>(
&self,
id: &str,
apply: F,
) -> Result<(), PersistenceError>where
F: FnOnce(&mut ArchiveEntry),
Edit the archive entry (title, state, roster, activity timestamp). The session id is pinned to the directory; titles stay bounded.
pub fn set_title( &self, id: &str, title: impl AsRef<str>, ) -> Result<(), PersistenceError>
pub fn set_state( &self, id: &str, state: ArchiveState, ) -> Result<(), PersistenceError>
Sourcepub fn touch(&self, id: &str) -> Result<(), PersistenceError>
pub fn touch(&self, id: &str) -> Result<(), PersistenceError>
Mark the session as most recently active.
Sourcepub fn buffered(&self, id: &str) -> Result<BufferedSessionArchive>
pub fn buffered(&self, id: &str) -> Result<BufferedSessionArchive>
Start a background writer that keeps journal and metadata filesystem
work off the caller thread. Events and metadata edits become durable
at BufferedSessionArchive::flush boundaries and on drop.
Sourcepub fn buffered_with_errors<F>(
&self,
id: &str,
on_error: F,
) -> Result<BufferedSessionArchive>
pub fn buffered_with_errors<F>( &self, id: &str, on_error: F, ) -> Result<BufferedSessionArchive>
Like Self::buffered, reporting background write failures through
on_error so the terminal can surface them in the status ribbon.
Trait Implementations§
Source§impl Clone for SessionArchive
impl Clone for SessionArchive
Source§fn clone(&self) -> SessionArchive
fn clone(&self) -> SessionArchive
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more