pub struct SubscriptionManager { /* private fields */ }Expand description
Manages resource subscriptions across all sessions.
Thread-safe and can be shared across handlers and background tasks.
Implementations§
Source§impl SubscriptionManager
impl SubscriptionManager
Sourcepub async fn subscribe(&self, session_id: &SessionId, uri: &str) -> bool
pub async fn subscribe(&self, session_id: &SessionId, uri: &str) -> bool
Subscribe a session to a resource.
Returns true if this is a new subscription, false if already subscribed.
Sourcepub async fn unsubscribe(&self, session_id: &SessionId, uri: &str) -> bool
pub async fn unsubscribe(&self, session_id: &SessionId, uri: &str) -> bool
Unsubscribe a session from a resource.
Returns true if the subscription existed, false otherwise.
Sourcepub async fn unsubscribe_all(&self, session_id: &SessionId)
pub async fn unsubscribe_all(&self, session_id: &SessionId)
Unsubscribe a session from all resources.
Call this when a session disconnects.
Sourcepub async fn subscribers(&self, uri: &str) -> Vec<SessionId>
pub async fn subscribers(&self, uri: &str) -> Vec<SessionId>
Get all session IDs subscribed to a resource.
Sourcepub async fn subscriptions(&self, session_id: &SessionId) -> Vec<String>
pub async fn subscriptions(&self, session_id: &SessionId) -> Vec<String>
Get all resources a session is subscribed to.
Sourcepub async fn is_subscribed(&self, session_id: &SessionId, uri: &str) -> bool
pub async fn is_subscribed(&self, session_id: &SessionId, uri: &str) -> bool
Check if a session is subscribed to a resource.
Sourcepub async fn subscriber_count(&self, uri: &str) -> usize
pub async fn subscriber_count(&self, uri: &str) -> usize
Get the number of subscribers for a resource.
Sourcepub async fn total_subscriptions(&self) -> usize
pub async fn total_subscriptions(&self) -> usize
Get total number of active subscriptions.
Trait Implementations§
Source§impl Clone for SubscriptionManager
impl Clone for SubscriptionManager
Source§fn clone(&self) -> SubscriptionManager
fn clone(&self) -> SubscriptionManager
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 Default for SubscriptionManager
impl Default for SubscriptionManager
Source§fn default() -> SubscriptionManager
fn default() -> SubscriptionManager
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SubscriptionManager
impl !RefUnwindSafe for SubscriptionManager
impl Send for SubscriptionManager
impl Sync for SubscriptionManager
impl Unpin for SubscriptionManager
impl UnsafeUnpin for SubscriptionManager
impl !UnwindSafe for SubscriptionManager
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