pub trait SessionSource:
Send
+ Sync
+ 'static {
// Required methods
fn current_ulid(&self) -> Option<String>;
fn list(&self, limit: u32) -> Result<Vec<SessionSummary>, SessionError>;
fn find(&self, needle: &str) -> Result<SessionSummary, SessionError>;
fn list_events(
&self,
ulid: &str,
limit: u32,
) -> Result<Vec<ReplayEvent>, SessionError>;
fn save_label(&self, ulid: &str, label: &str) -> Result<(), SessionError>;
fn fork_from_current(&self) -> Result<Option<String>, SessionError>;
}Expand description
The dispatcher’s view of the session store. Implemented by the
TUI (wrapping a zero_session::Store + a label index on top
of milestones) and by test scaffolding that keeps every call
in-memory.
All methods take &self — impls are expected to handle
interior mutability. The SQLite-backed impl already does, via
the store’s own Mutex<Connection>.
Required Methods§
Sourcefn current_ulid(&self) -> Option<String>
fn current_ulid(&self) -> Option<String>
Ulid of the session currently being recorded into, if any.
None when persistence is disabled (--no-persist) — the
dispatcher surfaces a clear “persistence disabled” line
rather than pretending the save went through.
Sourcefn list(&self, limit: u32) -> Result<Vec<SessionSummary>, SessionError>
fn list(&self, limit: u32) -> Result<Vec<SessionSummary>, SessionError>
Newest-first list of up to limit sessions.
§Errors
Propagates backend IO errors; a listing that errors cannot be partially rendered without inviting mismatched counts.
Sourcefn find(&self, needle: &str) -> Result<SessionSummary, SessionError>
fn find(&self, needle: &str) -> Result<SessionSummary, SessionError>
Look up a single session by ulid or a human-assigned
label (see Self::save_label). Impls should match ulid
first (exact prefix match on at least 6 chars is fine —
ulids are time-sortable so a prefix rarely collides) and
fall through to label resolution.
§Errors
Returns SessionError::NotFound when no row matches the
argument. Any other error variant is a backend failure.
Sourcefn list_events(
&self,
ulid: &str,
limit: u32,
) -> Result<Vec<ReplayEvent>, SessionError>
fn list_events( &self, ulid: &str, limit: u32, ) -> Result<Vec<ReplayEvent>, SessionError>
All events for a session in seq order (oldest first), up
to limit. Mirrors zero_session::Store::list_events’s
semantics but returns this crate’s ReplayEvent.
§Errors
Propagates backend IO errors.
Sourcefn save_label(&self, ulid: &str, label: &str) -> Result<(), SessionError>
fn save_label(&self, ulid: &str, label: &str) -> Result<(), SessionError>
Associate a short human label with a session ulid. Labels
are stored as milestones (session.label.<label> →
<ulid>) so they survive CLI restarts and are queryable
without schema changes. Overwriting a label is fine — the
old one is silently reassigned.
§Errors
Propagates backend IO errors.
Sourcefn fork_from_current(&self) -> Result<Option<String>, SessionError>
fn fork_from_current(&self) -> Result<Option<String>, SessionError>
Start a new session whose parent_ulid is the current
one. The impl becomes the authority for the new session’s
ulid; returns it so the dispatcher can echo the fork line.
None is returned when persistence is disabled.
§Errors
Propagates backend IO errors.