Skip to main content

JsonlSessionStorage

Struct JsonlSessionStorage 

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

File-backed storage: holds full state in memory and persists to a JSONL file. Pi-compatible: loads from file on creation, appends on every write.

Implementations§

Source§

impl JsonlSessionStorage

Source

pub fn create( file_path: PathBuf, cwd: &str, session_id: &str, parent_session_path: Option<String>, ) -> Result<Self, String>

Create a new session at the given path. Writes the header.

Source

pub fn open(file_path: PathBuf) -> Result<Self, String>

Open an existing session file. Loads all entries into memory.

Trait Implementations§

Source§

impl SessionStorage for JsonlSessionStorage

Source§

fn metadata(&self) -> SessionMetadata

Return header-derived metadata.
Source§

fn get_leaf_id(&self) -> Option<String>

Get the current leaf entry ID (the last non-leaf entry, resolved through leaf entries). Returns None if no entries exist.
Source§

fn set_leaf_id(&mut self, leaf_id: Option<&str>) -> Result<(), String>

Persist a leaf entry that records the active session-tree leaf. None means reset to no leaf.
Source§

fn create_entry_id(&self) -> String

Generate a unique 8-character hex entry ID, collision-checked.
Source§

fn append_entry(&mut self, entry: SessionEntry) -> Result<(), String>

Append a fully-constructed entry. Updates in-memory state and persists to disk.
Source§

fn get_entry(&self, id: &str) -> Option<SessionEntry>

Look up an entry by ID.
Source§

fn find_entries(&self, type_name: &str) -> Vec<SessionEntry>

Find all entries of the given type string.
Source§

fn get_label(&self, id: &str) -> Option<String>

Get the human-readable label for an entry, if any.
Source§

fn get_path_to_root( &self, leaf_id: Option<&str>, ) -> Result<Vec<SessionEntry>, String>

Walk from leaf_id (or current leaf, if None) to root, returning entries in path order.
Source§

fn get_entries(&self) -> Vec<SessionEntry>

Return all entries in insertion order.
Source§

fn path(&self) -> Option<&Path>

The file path on disk, if this storage is file-backed.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more