pub struct SessionManager { /* private fields */ }Expand description
Session manager with SQLite persistence
Implementations§
Source§impl SessionManager
impl SessionManager
Sourcepub fn new(db_path: impl AsRef<Path>) -> AgencyResult<Self>
pub fn new(db_path: impl AsRef<Path>) -> AgencyResult<Self>
Create a new session manager with the given database path
Sourcepub fn in_memory() -> AgencyResult<Self>
pub fn in_memory() -> AgencyResult<Self>
Create an in-memory session manager (for testing)
Sourcepub fn create(
&self,
agent_name: impl Into<String>,
user_id: Option<String>,
) -> AgencyResult<Session>
pub fn create( &self, agent_name: impl Into<String>, user_id: Option<String>, ) -> AgencyResult<Session>
Create a new session
Sourcepub fn save(&self, session: &Session) -> AgencyResult<()>
pub fn save(&self, session: &Session) -> AgencyResult<()>
Save a session
Sourcepub fn list_by_agent(
&self,
agent_name: &str,
limit: Option<u32>,
) -> AgencyResult<Vec<Session>>
pub fn list_by_agent( &self, agent_name: &str, limit: Option<u32>, ) -> AgencyResult<Vec<Session>>
List sessions for an agent
Sourcepub fn list_by_user(
&self,
user_id: &str,
limit: Option<u32>,
) -> AgencyResult<Vec<Session>>
pub fn list_by_user( &self, user_id: &str, limit: Option<u32>, ) -> AgencyResult<Vec<Session>>
List sessions for a user
Sourcepub fn delete(&self, id: &str) -> AgencyResult<bool>
pub fn delete(&self, id: &str) -> AgencyResult<bool>
Delete a session
Auto Trait Implementations§
impl Freeze for SessionManager
impl RefUnwindSafe for SessionManager
impl Send for SessionManager
impl Sync for SessionManager
impl Unpin 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