pub struct SessionTopicMap<T, TX> { /* private fields */ }Expand description
Map of generic topics to session ids and of session ids to a channel sender.
Implementations§
Source§impl<T, TX> SessionTopicMap<T, TX>
impl<T, TX> SessionTopicMap<T, TX>
Sourcepub fn insert_with_topic(&mut self, session_id: u64, topic: T, tx: TX)
pub fn insert_with_topic(&mut self, session_id: u64, topic: T, tx: TX)
Insert a session id with their topic and tx channel.
Sourcepub fn drop(&mut self, session_id: u64) -> bool
pub fn drop(&mut self, session_id: u64) -> bool
Drop a session from all mappings.
Returns true if the session existed and was dropped, otherwise returns false when the session was known
Sourcepub fn topic(&self, session_id: u64) -> Option<&T>
pub fn topic(&self, session_id: u64) -> Option<&T>
Get the topic for a session id.
Returns None of the session id was not known.
Sourcepub fn sessions(&self, topic: &T) -> HashSet<u64>
pub fn sessions(&self, topic: &T) -> HashSet<u64>
Get ids for all sessions associated with the given topic.
Sourcepub fn sender_mut(&mut self, session_id: u64) -> Option<&mut TX>
pub fn sender_mut(&mut self, session_id: u64) -> Option<&mut TX>
Get a mutable reference to a session sender.
Trait Implementations§
Source§impl<T: Clone, TX: Clone> Clone for SessionTopicMap<T, TX>
impl<T: Clone, TX: Clone> Clone for SessionTopicMap<T, TX>
Source§fn clone(&self) -> SessionTopicMap<T, TX>
fn clone(&self) -> SessionTopicMap<T, TX>
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 moreAuto Trait Implementations§
impl<T, TX> Freeze for SessionTopicMap<T, TX>
impl<T, TX> RefUnwindSafe for SessionTopicMap<T, TX>where
TX: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, TX> Send for SessionTopicMap<T, TX>
impl<T, TX> Sync for SessionTopicMap<T, TX>
impl<T, TX> Unpin for SessionTopicMap<T, TX>
impl<T, TX> UnwindSafe for SessionTopicMap<T, TX>where
TX: UnwindSafe,
T: UnwindSafe,
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