pub struct SubscriptionIndex { /* private fields */ }Implementations§
Source§impl SubscriptionIndex
impl SubscriptionIndex
pub const fn new() -> Self
pub fn is_empty(&self) -> bool
Sourcepub fn subscribe(&mut self, peer: PeerKey, prefix: Bytes)
pub fn subscribe(&mut self, peer: PeerKey, prefix: Bytes)
Adds a subscription for peer to prefix.
Complexity:
- O(log N) to find
- O(N) for insertion shift in the vec (acceptable for typical ZMQ sizes)
Sourcepub fn unsubscribe(&mut self, peer: PeerKey, prefix: &Bytes)
pub fn unsubscribe(&mut self, peer: PeerKey, prefix: &Bytes)
Removes a subscription for peer from prefix.
Sourcepub fn remove_peer_everywhere(&mut self, peer: PeerKey)
pub fn remove_peer_everywhere(&mut self, peer: PeerKey)
Remove peer from every prefix (used on disconnect).
Complexity: O(N) scan, acceptable on churn events.
Sourcepub fn match_topic(&self, topic: &[u8]) -> SmallVec<[PeerKey; 16]>
pub fn match_topic(&self, topic: &[u8]) -> SmallVec<[PeerKey; 16]>
Match a topic against all subscriptions.
Returns a deduplicated list of PeerKeys.
Hot path characteristics:
- Forward scan over sorted prefixes.
- Early exit when prefix > topic lexicographically (cannot be a prefix).
- Starts-with check for actual prefix match.
Trait Implementations§
Source§impl Debug for SubscriptionIndex
impl Debug for SubscriptionIndex
Source§impl Default for SubscriptionIndex
impl Default for SubscriptionIndex
Source§fn default() -> SubscriptionIndex
fn default() -> SubscriptionIndex
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SubscriptionIndex
impl RefUnwindSafe for SubscriptionIndex
impl Send for SubscriptionIndex
impl Sync for SubscriptionIndex
impl Unpin for SubscriptionIndex
impl UnsafeUnpin for SubscriptionIndex
impl UnwindSafe for SubscriptionIndex
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more