Skip to main content

SessionStore

Struct SessionStore 

Source
pub struct SessionStore { /* private fields */ }
Expand description

The store of named sessions.

Implementations§

Source§

impl SessionStore

Source

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

A store rooted at dir. The directory is created lazily on first write.

Source

pub fn default_dir() -> Option<PathBuf>

The default per-user location: $XDG_STATE_HOME/agent-abstraction/sessions (falling back to ~/.local/state), or %LOCALAPPDATA% on Windows. None when neither the platform state dir nor $HOME can be resolved.

Source

pub fn path_of(&self, project: &Path, name: &str) -> PathBuf

The file backing name for project. Pure path arithmetic.

The agent is not part of the key on purpose: one name must resolve to one file across agents, so asking for a Claude session under a name Codex already owns is a loud Error::SessionConflict rather than two unrelated conversations quietly sharing a name.

Source

pub fn get(&self, project: &Path, name: &str) -> Result<Option<SessionRecord>>

The stored record, or None when there is none.

Only a genuinely absent file is Ok(None). A permission error, an I/O failure or a corrupt record is an Error::Store, because treating those as “no session” silently starts a new conversation and abandons one the caller believes they are still in.

§Errors

Error::Store if the record exists but cannot be read or parsed.

Source

pub fn list(&self, project: &Path) -> Result<Vec<SessionRecord>>

Every session recorded for project, in unspecified order.

A record that cannot be read or parsed is an error rather than an omission: silently returning a short list makes a corrupt store look like a store with fewer sessions. Use SessionStore::list_lossy when skipping bad records is genuinely what you want.

§Errors

Error::Store if the directory or any record within it is unreadable.

Source

pub fn list_lossy(&self, project: &Path) -> Vec<SessionRecord>

Every readable session for project, skipping any that are not.

The deliberately lossy counterpart to SessionStore::list, for a UI that would rather show the sessions it can than fail the whole listing.

Source

pub fn bind( &self, agent: Agent, project: &Path, name: &str, token: &str, ) -> Result<SessionRecord>

Record token as the handle for name, preserving the original creation time when the session already existed.

§Errors

Error::Store if the record cannot be written.

Source

pub fn forget(&self, project: &Path, name: &str) -> Result<()>

Drop the binding for name. Removing an absent session is not an error.

§Errors

Error::Store if an existing record cannot be removed.

Trait Implementations§

Source§

impl Clone for SessionStore

Source§

fn clone(&self) -> SessionStore

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 SessionStore

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.