pub struct SessionPersistence { /* private fields */ }Expand description
Session persistence for auto-save/load
Implementations§
Source§impl SessionPersistence
impl SessionPersistence
Sourcepub fn save_user_message(
&self,
session_id: &str,
content: &str,
timestamp: i64,
) -> Result<(), Error>
pub fn save_user_message( &self, session_id: &str, content: &str, timestamp: i64, ) -> Result<(), Error>
Save a user message to the session file
Sourcepub fn save_assistant_message(
&self,
session_id: &str,
content: &str,
timestamp: i64,
) -> Result<(), Error>
pub fn save_assistant_message( &self, session_id: &str, content: &str, timestamp: i64, ) -> Result<(), Error>
Save an assistant message to the session file
Sourcepub fn load_session(&self, session_id: &str) -> Result<Vec<SessionEntry>, Error>
pub fn load_session(&self, session_id: &str) -> Result<Vec<SessionEntry>, Error>
Load a session from the session file
Sourcepub fn session_exists(&self, session_id: &str) -> bool
pub fn session_exists(&self, session_id: &str) -> bool
Check if a session file exists
Sourcepub fn should_auto_save(&self) -> bool
pub fn should_auto_save(&self) -> bool
Check if it’s time to auto-save
Sourcepub fn set_last_user_message(&self, msg: String)
pub fn set_last_user_message(&self, msg: String)
Update the last user message
Sourcepub fn get_last_user_message(&self) -> String
pub fn get_last_user_message(&self) -> String
Get the last user message
Auto Trait Implementations§
impl !Freeze for SessionPersistence
impl RefUnwindSafe for SessionPersistence
impl Send for SessionPersistence
impl Sync for SessionPersistence
impl Unpin for SessionPersistence
impl UnsafeUnpin for SessionPersistence
impl UnwindSafe for SessionPersistence
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