pub struct SessionTree { /* private fields */ }Expand description
In-memory tree structure for session entries
Implementations§
Source§impl SessionTree
impl SessionTree
Sourcepub fn from_entries(
entries: Vec<SessionEntry>,
session_id: String,
cwd: String,
) -> Result<Self, SessionTreeError>
pub fn from_entries( entries: Vec<SessionEntry>, session_id: String, cwd: String, ) -> Result<Self, SessionTreeError>
Load from existing entries
Sourcepub fn append(&mut self, entry: SessionEntry) -> Result<(), SessionTreeError>
pub fn append(&mut self, entry: SessionEntry) -> Result<(), SessionTreeError>
Append a new entry as child of current leaf
Sourcepub fn build_context(
&self,
leaf_id: &str,
) -> Result<Vec<Message>, SessionTreeError>
pub fn build_context( &self, leaf_id: &str, ) -> Result<Vec<Message>, SessionTreeError>
Build message context from leaf to root
Sourcepub fn branch_from(
&mut self,
entry_id: &str,
) -> Result<EntryId, SessionTreeError>
pub fn branch_from( &mut self, entry_id: &str, ) -> Result<EntryId, SessionTreeError>
Create a branch from a specific entry
Sourcepub fn entries(&self) -> Vec<&SessionEntry>
pub fn entries(&self) -> Vec<&SessionEntry>
Get all entries
Sourcepub fn session_id(&self) -> &str
pub fn session_id(&self) -> &str
Get session ID
Sourcepub fn save_to_file(&self, path: &Path) -> Result<(), SessionTreeError>
pub fn save_to_file(&self, path: &Path) -> Result<(), SessionTreeError>
Save tree to JSONL file
Sourcepub fn load_from_file(path: &Path) -> Result<Self, SessionTreeError>
pub fn load_from_file(path: &Path) -> Result<Self, SessionTreeError>
Load tree from JSONL file
Sourcepub fn append_to_file(
&self,
path: &Path,
entry: &SessionEntry,
) -> Result<(), SessionTreeError>
pub fn append_to_file( &self, path: &Path, entry: &SessionEntry, ) -> Result<(), SessionTreeError>
Append a single entry to file (for incremental saves)
Auto Trait Implementations§
impl Freeze for SessionTree
impl RefUnwindSafe for SessionTree
impl Send for SessionTree
impl Sync for SessionTree
impl Unpin for SessionTree
impl UnsafeUnpin for SessionTree
impl UnwindSafe for SessionTree
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
Mutably borrows from an owned value. Read more
Source§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>
Converts
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>
Converts
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