pub struct SubscriptionTrie { /* private fields */ }Expand description
Efficient subscription storage using a sorted set for O(log N) operations.
Backed by a BTreeSet<Vec<u8>> which allows O(log N) prefix searching:
find the largest stored prefix ≤ the topic, then check if it is a prefix
of the topic. Subscribe/unsubscribe are also O(log N).
Implementations§
Source§impl SubscriptionTrie
impl SubscriptionTrie
Sourcepub fn unsubscribe(&mut self, prefix: &Bytes)
pub fn unsubscribe(&mut self, prefix: &Bytes)
Remove a subscription
Sourcepub fn matches(&self, topic: &[u8]) -> bool
pub fn matches(&self, topic: &[u8]) -> bool
Check if a topic matches any subscription
Returns true if the topic should be delivered. O(log N) using BTreeSet range lookup.
Sourcepub fn subscriptions(&self) -> Vec<Subscription>
pub fn subscriptions(&self) -> Vec<Subscription>
Get all subscriptions as a Vec<Subscription>.
Trait Implementations§
Source§impl Debug for SubscriptionTrie
impl Debug for SubscriptionTrie
Source§impl Default for SubscriptionTrie
impl Default for SubscriptionTrie
Source§fn default() -> SubscriptionTrie
fn default() -> SubscriptionTrie
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SubscriptionTrie
impl RefUnwindSafe for SubscriptionTrie
impl Send for SubscriptionTrie
impl Sync for SubscriptionTrie
impl Unpin for SubscriptionTrie
impl UnsafeUnpin for SubscriptionTrie
impl UnwindSafe for SubscriptionTrie
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