pub enum Pattern {
Leaf(LeafPattern),
Structure(StructurePattern),
Meta(MetaPattern),
}Expand description
The main pattern type used for matching envelopes.
Variants§
Leaf(LeafPattern)
Leaf patterns for matching CBOR values.
Structure(StructurePattern)
Structure patterns for matching envelope elements.
Meta(MetaPattern)
Meta-patterns for combining and modifying other patterns.
Implementations§
Source§impl Pattern
impl Pattern
Sourcepub fn cbor(cbor: impl CBOREncodable) -> Self
pub fn cbor(cbor: impl CBOREncodable) -> Self
Creates a new Pattern that matches a specific CBOR value.
Sourcepub fn cbor_pattern(pattern: DCBORPattern) -> Self
pub fn cbor_pattern(pattern: DCBORPattern) -> Self
Creates a new Pattern that matches CBOR values using dcbor-pattern
expressions.
Source§impl Pattern
impl Pattern
Source§impl Pattern
impl Pattern
Sourcepub fn date(date: Date) -> Self
pub fn date(date: Date) -> Self
Creates a new Pattern that matches a specific Date (CBOR tag 1) value.
Sourcepub fn date_range(range: RangeInclusive<Date>) -> Self
pub fn date_range(range: RangeInclusive<Date>) -> Self
Creates a new Pattern that matches Date (CBOR tag 1) values within a
specified range (inclusive).
Sourcepub fn date_earliest(date: Date) -> Self
pub fn date_earliest(date: Date) -> Self
Creates a new Pattern that matches Date (CBOR tag 1) values that are
on or after the specified date.
Sourcepub fn date_latest(date: Date) -> Self
pub fn date_latest(date: Date) -> Self
Creates a new Pattern that matches Date (CBOR tag 1) values that are
on or before the specified date.
Sourcepub fn date_iso8601(iso_string: impl Into<String>) -> Self
pub fn date_iso8601(iso_string: impl Into<String>) -> Self
Creates a new Pattern that matches Date (CBOR tag 1) values by their
ISO-8601 string representation.
Sourcepub fn date_regex(regex: Regex) -> Self
pub fn date_regex(regex: Regex) -> Self
Creates a new Pattern that matches Date (CBOR tag 1) values whose
ISO-8601 string representation matches the given regular expression.
Source§impl Pattern
impl Pattern
Sourcepub fn any_number() -> Self
pub fn any_number() -> Self
Creates a new Pattern that matches any number value.
Sourcepub fn number<T: Into<f64>>(value: T) -> Self
pub fn number<T: Into<f64>>(value: T) -> Self
Creates a new Pattern that matches a specific number value.
Sourcepub fn number_range<A: Into<f64> + Copy>(range: RangeInclusive<A>) -> Self
pub fn number_range<A: Into<f64> + Copy>(range: RangeInclusive<A>) -> Self
Creates a new Pattern that matches number values within a specified
range (inclusive).
Sourcepub fn number_greater_than<T: Into<f64>>(value: T) -> Self
pub fn number_greater_than<T: Into<f64>>(value: T) -> Self
Creates a new Pattern that matches number values that are greater than
the specified value.
Sourcepub fn number_greater_than_or_equal<T: Into<f64>>(value: T) -> Self
pub fn number_greater_than_or_equal<T: Into<f64>>(value: T) -> Self
Creates a new Pattern that matches number values that are greater than
or equal to the specified value.
Sourcepub fn number_less_than<T: Into<f64>>(value: T) -> Self
pub fn number_less_than<T: Into<f64>>(value: T) -> Self
Creates a new Pattern that matches number values that are less than
the specified value.
Sourcepub fn number_less_than_or_equal<T: Into<f64>>(value: T) -> Self
pub fn number_less_than_or_equal<T: Into<f64>>(value: T) -> Self
Creates a new Pattern that matches number values that are less than or
equal to the specified value.
Sourcepub fn number_nan() -> Self
pub fn number_nan() -> Self
Creates a new Pattern that matches number values that are NaN (Not a
Number).
Source§impl Pattern
impl Pattern
Sourcepub fn any_byte_string() -> Self
pub fn any_byte_string() -> Self
Creates a new Pattern that matches any byte string value.
Sourcepub fn byte_string(value: impl AsRef<[u8]>) -> Self
pub fn byte_string(value: impl AsRef<[u8]>) -> Self
Creates a new Pattern that matches a specific byte string value.
Sourcepub fn byte_string_binary_regex(regex: Regex) -> Self
pub fn byte_string_binary_regex(regex: Regex) -> Self
Creates a new Pattern that matches byte string values that match the
given binary regular expression.
Source§impl Pattern
impl Pattern
pub fn any_known_value() -> Self
pub fn known_value(value: KnownValue) -> Self
pub fn known_value_named<T: Into<String>>(name: T) -> Self
pub fn known_value_regex(regex: Regex) -> Self
pub fn unit() -> Self
Source§impl Pattern
impl Pattern
pub fn any_array() -> Self
pub fn array_with_range(interval: impl RangeBounds<usize>) -> Self
pub fn array_with_count(count: usize) -> Self
Sourcepub fn array_from_dcbor_pattern(pattern: DCBORPattern) -> Self
pub fn array_from_dcbor_pattern(pattern: DCBORPattern) -> Self
Creates an array pattern from a dcbor-pattern. This is used internally by the parser to delegate to dcbor-pattern.
Source§impl Pattern
impl Pattern
pub fn any_map() -> Self
pub fn map_with_range(interval: impl RangeBounds<usize>) -> Self
pub fn map_with_count(count: usize) -> Self
Source§impl Pattern
impl Pattern
Sourcepub fn any_tag() -> Self
pub fn any_tag() -> Self
Creates a new Pattern that matches any tagged value.
This is a proxy to dcbor-pattern’s tagged functionality.
Sourcepub fn tagged(tag: impl Into<Tag>, pattern: DCBORPattern) -> Self
pub fn tagged(tag: impl Into<Tag>, pattern: DCBORPattern) -> Self
Creates a new Pattern that matches a specific tagged value with any
content. This is a proxy to dcbor-pattern’s tagged functionality.
Sourcepub fn tagged_name(name: impl Into<String>, pattern: DCBORPattern) -> Self
pub fn tagged_name(name: impl Into<String>, pattern: DCBORPattern) -> Self
Creates a new Pattern that matches a tagged value with specific tag
name and any content. This is a proxy to dcbor-pattern’s tagged
functionality.
Sourcepub fn tagged_regex(regex: Regex, pattern: DCBORPattern) -> Self
pub fn tagged_regex(regex: Regex, pattern: DCBORPattern) -> Self
Creates a new Pattern that matches a tagged value with tag name
matching regex and any content. This is a proxy to dcbor-pattern’s
tagged functionality.
Source§impl Pattern
impl Pattern
pub fn leaf() -> Self
pub fn any_assertion() -> Self
pub fn assertion_with_predicate(pattern: Pattern) -> Self
pub fn assertion_with_object(pattern: Pattern) -> Self
Source§impl Pattern
impl Pattern
pub fn any_predicate() -> Self
pub fn predicate(pattern: Pattern) -> Self
pub fn any_object() -> Self
pub fn object(pattern: Pattern) -> Self
Source§impl Pattern
impl Pattern
pub fn digest(digest: Digest) -> Self
pub fn digest_prefix(prefix: impl AsRef<[u8]>) -> Self
pub fn digest_binary_regex(regex: Regex) -> Self
pub fn any_node() -> Self
pub fn node_with_assertions_range(range: impl RangeBounds<usize>) -> Self
pub fn node_with_assertions_count(count: usize) -> Self
pub fn obscured() -> Self
pub fn elided() -> Self
pub fn encrypted() -> Self
pub fn compressed() -> Self
Source§impl Pattern
impl Pattern
Sourcepub fn not_matching(pattern: Pattern) -> Self
pub fn not_matching(pattern: Pattern) -> Self
Creates a new Pattern that negates another pattern; matches if the
specified pattern does not match.
Source§impl Pattern
impl Pattern
Sourcepub fn repeat(
pattern: Pattern,
interval: impl RangeBounds<usize>,
reluctance: Reluctance,
) -> Self
pub fn repeat( pattern: Pattern, interval: impl RangeBounds<usize>, reluctance: Reluctance, ) -> Self
Creates a new Pattern that will match a pattern repeated a number of
times according to the specified range and greediness.
In regex terms:
| Range | Quantifier |
|---|---|
.. | * |
1.. | + |
0..=1 | ? |
min..=max | {min,max} |
min.. | {min,} |
..=max | {0,max} |
n..=n | {n} |
pub fn group(pattern: Pattern) -> Self
Source§impl Pattern
impl Pattern
Sourcepub fn wrapped() -> Self
pub fn wrapped() -> Self
Creates a new Pattern that matches any wrapped envelope without
descending. Renamed from wrapped() to break tests so they can be
fixed.
Sourcepub fn unwrap_matching(pattern: Pattern) -> Self
pub fn unwrap_matching(pattern: Pattern) -> Self
Creates a new Pattern that matches a wrapped envelope and also matches
on its unwrapped content.
Trait Implementations§
impl Eq for Pattern
impl StructuralPartialEq for Pattern
Auto Trait Implementations§
impl Freeze for Pattern
impl RefUnwindSafe for Pattern
impl Send for Pattern
impl Sync for Pattern
impl Unpin for Pattern
impl UnwindSafe for Pattern
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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