pub struct SessionManager { /* private fields */ }Expand description
Session manager for managing agent sessions with a pluggable backend
Implementations§
Source§impl SessionManager
impl SessionManager
Sourcepub fn new(backend: Arc<dyn MemoryBackend>) -> Self
pub fn new(backend: Arc<dyn MemoryBackend>) -> Self
Create a new session manager with the given backend
Sourcepub fn sled<P: AsRef<Path>>(path: P) -> Result<Self, MemoryError>
pub fn sled<P: AsRef<Path>>(path: P) -> Result<Self, MemoryError>
Create a session manager with Sled backend
Sourcepub fn sled_temporary() -> Result<Self, MemoryError>
pub fn sled_temporary() -> Result<Self, MemoryError>
Create a session manager with temporary Sled backend (for testing)
Sourcepub fn backend(&self) -> &dyn MemoryBackend
pub fn backend(&self) -> &dyn MemoryBackend
Get the backend reference
Sourcepub async fn create_session(
&self,
agent_id: &str,
) -> Result<Session, MemoryError>
pub async fn create_session( &self, agent_id: &str, ) -> Result<Session, MemoryError>
Create a new session for an agent
Sourcepub async fn get_or_create_session(
&self,
agent_id: &str,
session_id: Option<&str>,
) -> Result<Session, MemoryError>
pub async fn get_or_create_session( &self, agent_id: &str, session_id: Option<&str>, ) -> Result<Session, MemoryError>
Get or create a session for an agent
Sourcepub async fn resume_session(
&self,
token: &str,
) -> Result<Option<Session>, MemoryError>
pub async fn resume_session( &self, token: &str, ) -> Result<Option<Session>, MemoryError>
Resume a session using a resume token
Sourcepub async fn save_session(&self, session: &Session) -> Result<(), MemoryError>
pub async fn save_session(&self, session: &Session) -> Result<(), MemoryError>
Save a session
Sourcepub async fn add_message(
&self,
session_id: &str,
message: Message,
) -> Result<Session, MemoryError>
pub async fn add_message( &self, session_id: &str, message: Message, ) -> Result<Session, MemoryError>
Add a message to a session and save
Sourcepub async fn create_resume_token(
&self,
session_id: &str,
) -> Result<String, MemoryError>
pub async fn create_resume_token( &self, session_id: &str, ) -> Result<String, MemoryError>
Generate a resume token for a session
Sourcepub async fn delete_session(&self, session_id: &str) -> Result<(), MemoryError>
pub async fn delete_session(&self, session_id: &str) -> Result<(), MemoryError>
Delete a session
Sourcepub async fn list_sessions(
&self,
agent_id: &str,
) -> Result<Vec<Session>, MemoryError>
pub async fn list_sessions( &self, agent_id: &str, ) -> Result<Vec<Session>, MemoryError>
List all sessions for an agent
Sourcepub async fn clear_agent_sessions(
&self,
agent_id: &str,
) -> Result<usize, MemoryError>
pub async fn clear_agent_sessions( &self, agent_id: &str, ) -> Result<usize, MemoryError>
Clear all sessions for an agent
Auto Trait Implementations§
impl Freeze for SessionManager
impl !RefUnwindSafe for SessionManager
impl Send for SessionManager
impl Sync for SessionManager
impl Unpin for SessionManager
impl UnsafeUnpin for SessionManager
impl !UnwindSafe for SessionManager
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