Skip to main content

SessionArchive

Struct SessionArchive 

Source
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

Source

pub fn open(root: impl Into<PathBuf>) -> Self

Source

pub fn root(&self) -> &Path

Source

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.

Source

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.

Source

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.

Source

pub fn list_all(&self) -> Result<SessionListing, PersistenceError>

List every archived session, newest activity first.

Source

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.

Source

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.

Source

pub fn append_human( &self, id: &str, text: impl Into<String>, direct: bool, ) -> Result<(), PersistenceError>

Source

pub fn append_agent( &self, id: &str, event: &AgentEvent, ) -> Result<(), PersistenceError>

Source

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.

Source

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.

Source

pub fn set_title( &self, id: &str, title: impl AsRef<str>, ) -> Result<(), PersistenceError>

Source

pub fn set_state( &self, id: &str, state: ArchiveState, ) -> Result<(), PersistenceError>

Source

pub fn touch(&self, id: &str) -> Result<(), PersistenceError>

Mark the session as most recently active.

Source

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.

Source

pub fn buffered_with_errors<F>( &self, id: &str, on_error: F, ) -> Result<BufferedSessionArchive>
where F: Fn(String) + Send + 'static,

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

Source§

fn clone(&self) -> SessionArchive

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SessionArchive

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.