pub struct TopicPattern { /* private fields */ }Expand description
Topic pattern matcher for AMQP-style topic routing
Supports wildcards:
*(star) matches exactly one word#(hash) matches zero or more words- Words are separated by dots (
.)
§Examples
use celers_core::router::TopicPattern;
let pattern = TopicPattern::new("user.*.created");
assert!(pattern.matches("user.email.created"));
assert!(pattern.matches("user.profile.created"));
assert!(!pattern.matches("user.created")); // No middle word
assert!(!pattern.matches("user.email.verified.created")); // Too many words
let pattern = TopicPattern::new("user.#");
assert!(pattern.matches("user.email"));
assert!(pattern.matches("user.email.created"));
assert!(pattern.matches("user.email.verified.sent"));
assert!(!pattern.matches("admin.email")); // Doesn't start with "user"Implementations§
Source§impl TopicPattern
impl TopicPattern
Sourcepub fn matches(&self, routing_key: &str) -> bool
pub fn matches(&self, routing_key: &str) -> bool
Check if a routing key matches this topic pattern
Sourcepub const fn complexity(&self) -> usize
pub const fn complexity(&self) -> usize
Get pattern complexity (number of segments)
Sourcepub fn has_wildcards(&self) -> bool
pub fn has_wildcards(&self) -> bool
Check if pattern contains wildcards
Trait Implementations§
Source§impl Clone for TopicPattern
impl Clone for TopicPattern
Source§fn clone(&self) -> TopicPattern
fn clone(&self) -> TopicPattern
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 moreAuto Trait Implementations§
impl Freeze for TopicPattern
impl RefUnwindSafe for TopicPattern
impl Send for TopicPattern
impl Sync for TopicPattern
impl Unpin for TopicPattern
impl UnwindSafe for TopicPattern
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