pub struct SessionStore { /* private fields */ }Expand description
Session store for persistence.
Directory creation is lazy — the sessions directory is only created on
the first call to save, not at construction time.
Implementations§
Source§impl SessionStore
impl SessionStore
Sourcepub fn new(sessions_dir: impl AsRef<Path>) -> Self
pub fn new(sessions_dir: impl AsRef<Path>) -> Self
Create a new session store pointing at an explicit directory.
The directory is not created immediately — it will be created lazily on the first save.
Sourcepub fn from_home(home: &AstridHome) -> Self
pub fn from_home(home: &AstridHome) -> Self
Create a session store from an AstridHome.
Sessions will be stored in ~/.astrid/sessions/.
The directory is created lazily on first save.
Sourcepub fn save(&self, session: &AgentSession) -> RuntimeResult<()>
pub fn save(&self, session: &AgentSession) -> RuntimeResult<()>
Save a session atomically.
Writes to a temporary file first, then renames. This prevents corruption if the process crashes mid-write (session auto-saves after every turn).
§Errors
Returns an error if the session cannot be serialized or written to disk.
Sourcepub fn load(&self, id: &SessionId) -> RuntimeResult<Option<AgentSession>>
pub fn load(&self, id: &SessionId) -> RuntimeResult<Option<AgentSession>>
Sourcepub fn load_by_str(&self, id: &str) -> RuntimeResult<Option<AgentSession>>
pub fn load_by_str(&self, id: &str) -> RuntimeResult<Option<AgentSession>>
Load a session by ID string.
§Errors
Returns an error if the ID is not a valid UUID or the session cannot be loaded.
Sourcepub fn delete(&self, id: &SessionId) -> RuntimeResult<()>
pub fn delete(&self, id: &SessionId) -> RuntimeResult<()>
Sourcepub fn list(&self) -> RuntimeResult<Vec<SessionId>>
pub fn list(&self) -> RuntimeResult<Vec<SessionId>>
List all session IDs, sorted by modification time (most recent first).
Returns an empty list if the sessions directory does not exist yet.
§Errors
Returns an error if the sessions directory cannot be read.
Sourcepub fn list_with_metadata(&self) -> RuntimeResult<Vec<SessionSummary>>
pub fn list_with_metadata(&self) -> RuntimeResult<Vec<SessionSummary>>
Sourcepub fn most_recent(&self) -> RuntimeResult<Option<AgentSession>>
pub fn most_recent(&self) -> RuntimeResult<Option<AgentSession>>
Sourcepub fn list_for_workspace(
&self,
workspace: &Path,
) -> RuntimeResult<Vec<SessionSummary>>
pub fn list_for_workspace( &self, workspace: &Path, ) -> RuntimeResult<Vec<SessionSummary>>
List sessions filtered by workspace path.
Only returns sessions whose workspace_path matches the given path.
§Errors
Returns an error if sessions cannot be listed or loaded.
Sourcepub fn cleanup_old(&self, max_age_days: i64) -> RuntimeResult<usize>
pub fn cleanup_old(&self, max_age_days: i64) -> RuntimeResult<usize>
Clean up old sessions (older than N days).
§Errors
Returns an error if the sessions cannot be listed.
Auto Trait Implementations§
impl !Freeze for SessionStore
impl RefUnwindSafe for SessionStore
impl Send for SessionStore
impl Sync for SessionStore
impl Unpin for SessionStore
impl UnsafeUnpin for SessionStore
impl UnwindSafe for SessionStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more