Enum Pattern

Source
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

Source

pub fn parse(input: impl AsRef<str>) -> Result<Pattern>

Parse a pattern expression.

Source§

impl Pattern

Source

pub fn any_leaf() -> Self

Creates a new Pattern that matches any leaf.

Source§

impl Pattern

Source

pub fn any_cbor() -> Self

Creates a new Pattern that matches any CBOR value.

Source

pub fn cbor(cbor: impl CBOREncodable) -> Self

Creates a new Pattern that matches a specific CBOR value.

Source§

impl Pattern

Source

pub fn any_bool() -> Self

Creates a new Pattern that matches any boolean value.

Source

pub fn bool(b: bool) -> Self

Creates a new Pattern that matches a specific boolean value.

Source§

impl Pattern

Source

pub fn any_text() -> Self

Creates a new Pattern that matches any text value.

Source

pub fn text<T: Into<String>>(value: T) -> Self

Creates a new Pattern that matches a specific text value.

Source

pub fn text_regex(regex: Regex) -> Self

Creates a new Pattern that matches text values that match the given regular expression.

Source§

impl Pattern

Source

pub fn any_date() -> Self

Creates a new Pattern that matches any Date (CBOR tag 1) value.

Source

pub fn date(date: Date) -> Self

Creates a new Pattern that matches a specific Date (CBOR tag 1) value.

Source

pub fn date_range(range: RangeInclusive<Date>) -> Self

Creates a new Pattern that matches Date (CBOR tag 1) values within a specified range (inclusive).

Source

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.

Source

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.

Source

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.

Source

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

Source

pub fn any_number() -> Self

Creates a new Pattern that matches any number value.

Source

pub fn number<T: Into<f64>>(value: T) -> Self

Creates a new Pattern that matches a specific number value.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn number_nan() -> Self

Creates a new Pattern that matches number values that are NaN (Not a Number).

Source§

impl Pattern

Source

pub fn any_byte_string() -> Self

Creates a new Pattern that matches any byte string value.

Source

pub fn byte_string(value: impl AsRef<[u8]>) -> Self

Creates a new Pattern that matches a specific byte string value.

Source

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

Source

pub fn any_known_value() -> Self

Source

pub fn known_value(value: KnownValue) -> Self

Source

pub fn known_value_named<T: Into<String>>(name: T) -> Self

Source

pub fn known_value_regex(regex: Regex) -> Self

Source

pub fn unit() -> Self

Source§

impl Pattern

Source

pub fn any_array() -> Self

Source

pub fn array_with_range(interval: impl RangeBounds<usize>) -> Self

Source

pub fn array_with_count(count: usize) -> Self

Source§

impl Pattern

Source

pub fn any_map() -> Self

Source

pub fn map_with_range(interval: impl RangeBounds<usize>) -> Self

Source

pub fn map_with_count(count: usize) -> Self

Source§

impl Pattern

Source

pub fn null() -> Self

Source§

impl Pattern

Source

pub fn any_tag() -> Self

Source

pub fn tagged(tag: Tag) -> Self

Source

pub fn tagged_with_value(value: u64) -> Self

Source

pub fn tagged_with_name(name: impl Into<String>) -> Self

Source

pub fn tagged_with_regex(regex: Regex) -> Self

Source§

impl Pattern

Source

pub fn any_assertion() -> Self

Source

pub fn assertion_with_predicate(pattern: Pattern) -> Self

Source

pub fn assertion_with_object(pattern: Pattern) -> Self

Source§

impl Pattern

Source

pub fn any_subject() -> Self

Source

pub fn subject(pattern: Pattern) -> Self

Source§

impl Pattern

Source

pub fn any_predicate() -> Self

Source

pub fn predicate(pattern: Pattern) -> Self

Source

pub fn any_object() -> Self

Source

pub fn object(pattern: Pattern) -> Self

Source§

impl Pattern

Source

pub fn digest(digest: Digest) -> Self

Source

pub fn digest_prefix(prefix: impl AsRef<[u8]>) -> Self

Source

pub fn digest_binary_regex(regex: Regex) -> Self

Source

pub fn any_node() -> Self

Source

pub fn node_with_assertions_range(range: impl RangeBounds<usize>) -> Self

Source

pub fn node_with_assertions_count(count: usize) -> Self

Source

pub fn obscured() -> Self

Source

pub fn elided() -> Self

Source

pub fn encrypted() -> Self

Source

pub fn compressed() -> Self

Source§

impl Pattern

Source

pub fn any() -> Self

Creates a new Pattern that matches any element.

Source

pub fn none() -> Self

Creates a new Pattern that never matches any element.

Source§

impl Pattern

Source

pub fn and(patterns: Vec<Pattern>) -> Self

Creates a new Pattern that only matches if all specified patterns match.

Source

pub fn or(patterns: Vec<Pattern>) -> Self

Creates a new Pattern that matches if at least one of the specified patterns matches.

Source§

impl Pattern

Source

pub fn sequence(patterns: Vec<Pattern>) -> Self

Creates a new Pattern that matches a sequence of patterns in order.

Source§

impl Pattern

Source

pub fn search(pattern: Pattern) -> Self

Creates a new Pattern that searches for a specific pattern within the envelope. Useful for finding patterns that may not be at the root of the envelope.

Source§

impl Pattern

Source

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

Source

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:

RangeQuantifier
..*
1..+
0..=1?
min..=max{min,max}
min..{min,}
..=max{0,max}
n..=n{n}
Source

pub fn group(pattern: Pattern) -> Self

Source§

impl Pattern

Source

pub fn capture(name: impl AsRef<str>, pattern: Pattern) -> Self

Creates a new Pattern that will capture a pattern match with a name.

Source§

impl Pattern

Source

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.

Source

pub fn unwrap_matching(pattern: Pattern) -> Self

Creates a new Pattern that matches a wrapped envelope and also matches on its unwrapped content.

Source

pub fn unwrap() -> Self

Creates a new Pattern that matches any wrapped envelope and descends into it.

Trait Implementations§

Source§

impl Clone for Pattern

Source§

fn clone(&self) -> Pattern

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Pattern

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Pattern

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Pattern

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Pattern

Source§

fn eq(&self, other: &Pattern) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Pattern

Source§

impl StructuralPartialEq for Pattern

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,