pub struct Session { /* private fields */ }Expand description
Manages a session’s lifecycle: writing entries to the JSONL file.
Use SessionStore to create or load sessions. The Session type
handles the actual message appending, metadata updates, and auto-save.
Implementations§
Source§impl Session
impl Session
Sourcepub fn append_message(&mut self, message: &Message)
pub fn append_message(&mut self, message: &Message)
Append a message to the session file and update metadata.
Sourcepub fn set_token_usage(&mut self, usage: TokenUsage)
pub fn set_token_usage(&mut self, usage: TokenUsage)
Set the last known token usage reported by the provider. This is stored in the session metadata so it survives restarts.
Sourcepub fn add_tool_calls(&mut self, count: u64)
pub fn add_tool_calls(&mut self, count: u64)
Add to the cumulative tool call count for this session.
Sourcepub fn add_tokens_used(&mut self, count: u64)
pub fn add_tokens_used(&mut self, count: u64)
Add to the cumulative total tokens used in this session.
pub fn id(&self) -> &str
pub fn meta(&self) -> &SessionMeta
Trait Implementations§
Auto Trait Implementations§
impl Forget for Session
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl UnwindSafe for Session
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