pub struct SessionStore { /* private fields */ }Implementations§
Source§impl SessionStore
impl SessionStore
pub fn new(root: PathBuf) -> Self
Sourcepub fn symlink_path(&self, id: &SessionId) -> PathBuf
pub fn symlink_path(&self, id: &SessionId) -> PathBuf
Path of the <root>/<sid> entry – the symlink for explicitly-pathed
sessions, the directory itself for auto-allocated ones. Exposed so CLI
commands can name the path in user-facing messages without the store’s
root field leaking out.
Sourcepub fn create(
&self,
sid: &SessionId,
explicit_dir: Option<&Path>,
session: &mut Session,
) -> Result<PathBuf>
pub fn create( &self, sid: &SessionId, explicit_dir: Option<&Path>, session: &mut Session, ) -> Result<PathBuf>
Materialize a session on disk. create overwrites session.session_dir
with the resolved path so the caller doesn’t need to compute it twice
and the in-memory Session matches what got persisted. Returns the
same path for convenience.
Sourcepub fn finalize(
&self,
id: &SessionId,
ended_at: SystemTime,
exit_code: i32,
) -> Result<()>
pub fn finalize( &self, id: &SessionId, ended_at: SystemTime, exit_code: i32, ) -> Result<()>
Update ended_at + exit_code on a session that’s already on disk.
Read-modify-write; atomic on POSIX via tempfile::persist. Single-writer
assumption – if a future task adds heartbeating, revisit for lost-update.
Sourcepub fn list(&self) -> Result<Vec<Session>>
pub fn list(&self) -> Result<Vec<Session>>
Newest-first. Symlinked entries get link_target = Some(read_link_result).
Entries without a session.json are skipped silently (foreign content under
the root shouldn’t crash listings).
Sourcepub fn get_by_id(&self, id: &SessionId) -> Result<(PathBuf, Session)>
pub fn get_by_id(&self, id: &SessionId) -> Result<(PathBuf, Session)>
Resolve <root>/<id> (symlink-aware), return (actual_dir, Session)
with link_target set when applicable.
Sourcepub fn get_by_path(&self, dir: &Path) -> Result<Session>
pub fn get_by_path(&self, dir: &Path) -> Result<Session>
Read <dir>/session.json. link_target left None; the caller already
has the directory in hand, so symlink-status is its concern.
Sourcepub fn remove_by_id(&self, id: &SessionId) -> Result<()>
pub fn remove_by_id(&self, id: &SessionId) -> Result<()>
Auto session: remove the dir. Symlinked: remove the link target’s contents and the symlink.
Sourcepub fn remove_by_path(&self, dir: &Path) -> Result<()>
pub fn remove_by_path(&self, dir: &Path) -> Result<()>
rm -rf <dir>, then sweep <root> for any symlink whose target was
<dir> and remove it too. O(n) over root entries; fine for v0.
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