pub struct Registry<K> { /* private fields */ }Expand description
The subscriptions of a core, their topics and the state of each topic.
Several subscriptions may listen to one topic (two bots, or a quote stream and a book of depth 1): the exchange is asked once, the frames go to all of them.
Implementations§
Source§impl<K> Registry<K>
impl<K> Registry<K>
Sourcepub fn notifier(&self) -> Arc<Notify>
pub fn notifier(&self) -> Arc<Notify>
Woken whenever a topic changes state. The connector waits on it for the confirmation of a new subscription.
Sourcepub fn register(&mut self, id: SubscriptionId, kind: K, topics: Vec<String>)
pub fn register(&mut self, id: SubscriptionId, kind: K, topics: Vec<String>)
Registers a subscription for topics. A topic that already has subscriptions keeps its state.
Sourcepub fn add_request(&mut self, req_id: &str, topic: &str)
pub fn add_request(&mut self, req_id: &str, topic: &str)
Remembers that the answer carrying req_id is about topic.
Sourcepub fn forget(&mut self, id: SubscriptionId) -> Vec<String>
pub fn forget(&mut self, id: SubscriptionId) -> Vec<String>
Forgets a subscription. Returns the topics nobody listens to any more.
Sourcepub fn subs_of(&self, topic: &str) -> Vec<SubscriptionId>
pub fn subs_of(&self, topic: &str) -> Vec<SubscriptionId>
The subscriptions that listen to a topic.
Sourcepub fn topic_active(&self, topic: &str) -> bool
pub fn topic_active(&self, topic: &str) -> bool
Whether the exchange has confirmed the topic.
Sourcepub fn state(&self, id: SubscriptionId) -> Option<(SubState, Option<String>)>
pub fn state(&self, id: SubscriptionId) -> Option<(SubState, Option<String>)>
The state of a subscription: failed when any topic was refused, active when all are, else pending. With the reason of the refusal.
Sourcepub fn on_ack(&mut self, req_id: &str, success: bool, message: &str)
pub fn on_ack(&mut self, req_id: &str, success: bool, message: &str)
An answer of the exchange to a subscription request.
Sourcepub fn on_data(&mut self, topic: &str)
pub fn on_data(&mut self, topic: &str)
Data came on a topic: it is open, whatever the answer said.
Sourcepub fn fail_pending(&mut self, reason: &str)
pub fn fail_pending(&mut self, reason: &str)
The login was refused: every topic still waiting fails with the reason.