pub struct PatternSet { /* private fields */ }Expand description
A pattern set groups related patterns for a specific domain
§Example
use gatekpr_patterns::PatternSet;
let set = PatternSet::new("webhooks")
.with_pattern("gdpr_data_request", r"customers[/_]data[/_]request")
.with_pattern("gdpr_redact", r"customers[/_]redact")
.build()
.unwrap();
assert!(set.is_match("gdpr_data_request", "customers/data_request"));Implementations§
Source§impl PatternSet
impl PatternSet
Sourcepub fn with_pattern(self, key: &str, pattern: &str) -> Self
pub fn with_pattern(self, key: &str, pattern: &str) -> Self
Add a pattern to the set
Sourcepub fn with_patterns(self, patterns: &[(&str, &str)]) -> Self
pub fn with_patterns(self, patterns: &[(&str, &str)]) -> Self
Add multiple patterns at once
Sourcepub fn build(self) -> Result<PatternRegistry>
pub fn build(self) -> Result<PatternRegistry>
Build the pattern set into a registry
Auto Trait Implementations§
impl Freeze for PatternSet
impl RefUnwindSafe for PatternSet
impl Send for PatternSet
impl Sync for PatternSet
impl Unpin for PatternSet
impl UnsafeUnpin for PatternSet
impl UnwindSafe for PatternSet
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