pub struct SessionStore { /* private fields */ }Expand description
The store of named sessions.
Implementations§
Source§impl SessionStore
impl SessionStore
Sourcepub fn open(dir: impl Into<PathBuf>) -> Self
pub fn open(dir: impl Into<PathBuf>) -> Self
A store rooted at dir. The directory is created lazily on first write.
Sourcepub fn default_dir() -> Option<PathBuf>
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.
Sourcepub fn path_of(&self, project: &Path, name: &str) -> PathBuf
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.
Sourcepub fn get(&self, project: &Path, name: &str) -> Result<Option<SessionRecord>>
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.
Sourcepub fn list(&self, project: &Path) -> Result<Vec<SessionRecord>>
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.
Sourcepub fn list_lossy(&self, project: &Path) -> Vec<SessionRecord>
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.
Sourcepub fn bind(
&self,
agent: Agent,
project: &Path,
name: &str,
token: &str,
) -> Result<SessionRecord>
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.
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