pub struct SessionRouter { /* private fields */ }Expand description
Routes messages to the appropriate session Manages active session state and ensures messages are routed to the correct session
Implementations§
Source§impl SessionRouter
impl SessionRouter
Sourcepub fn create_session(
&mut self,
name: String,
context: SessionContext,
) -> SessionResult<Session>
pub fn create_session( &mut self, name: String, context: SessionContext, ) -> SessionResult<Session>
Create a new session and set it as active
Sourcepub fn route_to_active_session(
&mut self,
message_content: &str,
) -> SessionResult<String>
pub fn route_to_active_session( &mut self, message_content: &str, ) -> SessionResult<String>
Route a message to the active session Returns the session ID the message was routed to
Sourcepub fn route_to_session(
&mut self,
session_id: &str,
message_content: &str,
) -> SessionResult<String>
pub fn route_to_session( &mut self, session_id: &str, message_content: &str, ) -> SessionResult<String>
Route a message to a specific session Returns the session ID the message was routed to
Sourcepub fn get_active_session(&self) -> SessionResult<Session>
pub fn get_active_session(&self) -> SessionResult<Session>
Get the active session
Sourcepub fn get_session(&self, session_id: &str) -> SessionResult<Session>
pub fn get_session(&self, session_id: &str) -> SessionResult<Session>
Get a session by ID
Sourcepub fn switch_session(&mut self, session_id: &str) -> SessionResult<Session>
pub fn switch_session(&mut self, session_id: &str) -> SessionResult<Session>
Switch to a different session
Sourcepub fn active_session_id(&self) -> Option<&str>
pub fn active_session_id(&self) -> Option<&str>
Get the ID of the active session
Sourcepub fn list_sessions(&self) -> Vec<Session>
pub fn list_sessions(&self) -> Vec<Session>
List all sessions
Sourcepub fn get_message_session(&self, message_id: &str) -> Option<String>
pub fn get_message_session(&self, message_id: &str) -> Option<String>
Get which session a message belongs to
Sourcepub fn verify_message_in_session(
&self,
message_id: &str,
session_id: &str,
) -> bool
pub fn verify_message_in_session( &self, message_id: &str, session_id: &str, ) -> bool
Verify that a message belongs to a specific session
Sourcepub fn delete_session(&mut self, session_id: &str) -> SessionResult<()>
pub fn delete_session(&mut self, session_id: &str) -> SessionResult<()>
Delete a session
Sourcepub fn update_session(&mut self, session: Session) -> SessionResult<()>
pub fn update_session(&mut self, session: Session) -> SessionResult<()>
Update a session
Sourcepub fn session_count(&self) -> usize
pub fn session_count(&self) -> usize
Get the number of sessions
Trait Implementations§
Source§impl Clone for SessionRouter
impl Clone for SessionRouter
Source§fn clone(&self) -> SessionRouter
fn clone(&self) -> SessionRouter
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SessionRouter
impl Debug for SessionRouter
Auto Trait Implementations§
impl Freeze for SessionRouter
impl RefUnwindSafe for SessionRouter
impl Send for SessionRouter
impl Sync for SessionRouter
impl Unpin for SessionRouter
impl UnwindSafe for SessionRouter
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