pub struct SubscriptionManager { /* private fields */ }Expand description
Subscription manager
Implementations§
Source§impl SubscriptionManager
impl SubscriptionManager
Sourcepub async fn add_subscription(
&self,
stream: String,
symbol: String,
sub_type: SubscriptionType,
sender: Sender<Value>,
) -> Result<bool>
pub async fn add_subscription( &self, stream: String, symbol: String, sub_type: SubscriptionType, sender: Sender<Value>, ) -> Result<bool>
Adds a subscription to the manager.
If a subscription for the same stream already exists, increments the reference count instead of creating a duplicate subscription.
Returns true if a new subscription was created, false if an existing one was reused.
Sourcepub async fn remove_subscription(&self, stream: &str) -> Result<bool>
pub async fn remove_subscription(&self, stream: &str) -> Result<bool>
Removes a subscription by stream name.
Only actually removes the subscription when the reference count reaches zero.
Returns true if the subscription was fully removed (ref count hit zero).
Sourcepub async fn get_subscription(&self, stream: &str) -> Option<Subscription>
pub async fn get_subscription(&self, stream: &str) -> Option<Subscription>
Retrieves a subscription by stream name
Sourcepub async fn has_subscription(&self, stream: &str) -> bool
pub async fn has_subscription(&self, stream: &str) -> bool
Checks whether a subscription exists for the given stream
Sourcepub async fn get_all_subscriptions(&self) -> Vec<Subscription>
pub async fn get_all_subscriptions(&self) -> Vec<Subscription>
Returns all registered subscriptions
Sourcepub fn get_all_subscriptions_sync(&self) -> Vec<Subscription>
pub fn get_all_subscriptions_sync(&self) -> Vec<Subscription>
Returns all registered subscriptions synchronously (non-blocking)
Sourcepub async fn get_subscriptions_by_symbol(
&self,
symbol: &str,
) -> Vec<Subscription>
pub async fn get_subscriptions_by_symbol( &self, symbol: &str, ) -> Vec<Subscription>
Returns all subscriptions associated with a symbol
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Returns the number of active subscriptions
Sourcepub async fn send_to_stream(&self, stream: &str, message: Value) -> bool
pub async fn send_to_stream(&self, stream: &str, message: Value) -> bool
Sends a message to subscribers of a specific stream
Sourcepub async fn send_to_symbol(&self, symbol: &str, message: &Value) -> usize
pub async fn send_to_symbol(&self, symbol: &str, message: &Value) -> usize
Sends a message to all subscribers of a symbol
Sourcepub async fn get_active_streams(&self) -> Vec<String>
pub async fn get_active_streams(&self) -> Vec<String>
Returns a list of all active stream names for resubscription