pub enum DCBORPattern {
Value(ValuePattern),
Structure(StructurePattern),
Meta(MetaPattern),
}Variants§
Implementations§
Source§impl Pattern
impl Pattern
Sourcepub fn parse_partial(input: &str) -> Result<(Pattern, usize), Error>
pub fn parse_partial(input: &str) -> Result<(Pattern, usize), Error>
Parses a pattern from the beginning of a string and returns both the parsed Pattern and the number of bytes consumed.
Unlike parse(), this function succeeds even if additional
characters follow the first pattern. The returned index points to the
first unparsed character after the pattern.
§Example
let (pattern, consumed) = Pattern::parse_partial("true rest").unwrap();
assert_eq!(pattern, Pattern::bool(true));
assert_eq!(consumed, 5); // "true ".len() - includes whitespaceSource§impl Pattern
impl Pattern
Sourcepub fn any_number() -> Pattern
pub fn any_number() -> Pattern
Creates a pattern that matches any number value.
Sourcepub fn number_range<A>(range: RangeInclusive<A>) -> Pattern
pub fn number_range<A>(range: RangeInclusive<A>) -> Pattern
Creates a pattern that matches numbers within a range.
Sourcepub fn number_greater_than<T>(value: T) -> Pattern
pub fn number_greater_than<T>(value: T) -> Pattern
Creates a pattern that matches numbers greater than the specified value.
Sourcepub fn number_greater_than_or_equal<T>(value: T) -> Pattern
pub fn number_greater_than_or_equal<T>(value: T) -> Pattern
Creates a pattern that matches numbers greater than or equal to the specified value.
Sourcepub fn number_less_than<T>(value: T) -> Pattern
pub fn number_less_than<T>(value: T) -> Pattern
Creates a pattern that matches numbers less than the specified value.
Sourcepub fn number_less_than_or_equal<T>(value: T) -> Pattern
pub fn number_less_than_or_equal<T>(value: T) -> Pattern
Creates a pattern that matches numbers less than or equal to the specified value.
Sourcepub fn number_nan() -> Pattern
pub fn number_nan() -> Pattern
Creates a pattern that matches NaN values.
Sourcepub fn number_infinity() -> Pattern
pub fn number_infinity() -> Pattern
Creates a pattern that matches positive infinity values.
Sourcepub fn number_neg_infinity() -> Pattern
pub fn number_neg_infinity() -> Pattern
Creates a pattern that matches negative infinity values.
Sourcepub fn text_regex(regex: Regex) -> Pattern
pub fn text_regex(regex: Regex) -> Pattern
Creates a pattern that matches text using a regex.
Sourcepub fn any_byte_string() -> Pattern
pub fn any_byte_string() -> Pattern
Creates a pattern that matches any byte string value.
Sourcepub fn byte_string(value: impl AsRef<[u8]>) -> Pattern
pub fn byte_string(value: impl AsRef<[u8]>) -> Pattern
Creates a pattern that matches a specific byte string value.
Sourcepub fn byte_string_regex(regex: Regex) -> Pattern
pub fn byte_string_regex(regex: Regex) -> Pattern
Creates a pattern that matches byte strings using a binary regex.
Sourcepub fn date_range(range: RangeInclusive<Date>) -> Pattern
pub fn date_range(range: RangeInclusive<Date>) -> Pattern
Creates a pattern that matches dates within a range (inclusive).
Sourcepub fn date_earliest(date: Date) -> Pattern
pub fn date_earliest(date: Date) -> Pattern
Creates a pattern that matches dates that are on or after the specified date.
Sourcepub fn date_latest(date: Date) -> Pattern
pub fn date_latest(date: Date) -> Pattern
Creates a pattern that matches dates that are on or before the specified date.
Sourcepub fn date_iso8601(iso_string: impl Into<String>) -> Pattern
pub fn date_iso8601(iso_string: impl Into<String>) -> Pattern
Creates a pattern that matches a date by its ISO-8601 string representation.
Sourcepub fn date_regex(regex: Regex) -> Pattern
pub fn date_regex(regex: Regex) -> Pattern
Creates a pattern that matches dates whose ISO-8601 string representation matches the given regex pattern.
Sourcepub fn any_known_value() -> Pattern
pub fn any_known_value() -> Pattern
Creates a pattern that matches any known value.
Sourcepub fn known_value(value: KnownValue) -> Pattern
pub fn known_value(value: KnownValue) -> Pattern
Creates a pattern that matches a specific known value.
Sourcepub fn known_value_named(name: impl Into<String>) -> Pattern
pub fn known_value_named(name: impl Into<String>) -> Pattern
Creates a pattern that matches a known value by name.
Sourcepub fn known_value_regex(regex: Regex) -> Pattern
pub fn known_value_regex(regex: Regex) -> Pattern
Creates a pattern that matches known values using a regex on their names.
Sourcepub fn any_digest() -> Pattern
pub fn any_digest() -> Pattern
Creates a pattern that matches any digest value.
Sourcepub fn digest_prefix(prefix: impl AsRef<[u8]>) -> Pattern
pub fn digest_prefix(prefix: impl AsRef<[u8]>) -> Pattern
Creates a pattern that matches digests with the specified prefix.
Sourcepub fn digest_binary_regex(regex: Regex) -> Pattern
pub fn digest_binary_regex(regex: Regex) -> Pattern
Creates a pattern that matches digests using a binary regex.
Sourcepub fn and(patterns: Vec<Pattern>) -> Pattern
pub fn and(patterns: Vec<Pattern>) -> Pattern
Creates a pattern that matches if all contained patterns match.
Sourcepub fn or(patterns: Vec<Pattern>) -> Pattern
pub fn or(patterns: Vec<Pattern>) -> Pattern
Creates a pattern that matches if any contained pattern matches.
Sourcepub fn not_matching(pattern: Pattern) -> Pattern
pub fn not_matching(pattern: Pattern) -> Pattern
Creates a pattern that matches if the inner pattern does not match.
Sourcepub fn capture(name: impl AsRef<str>, pattern: Pattern) -> Pattern
pub fn capture(name: impl AsRef<str>, pattern: Pattern) -> Pattern
Creates a pattern that captures matches with the given name.
Sourcepub fn search(pattern: Pattern) -> Pattern
pub fn search(pattern: Pattern) -> Pattern
Creates a search pattern that recursively searches the entire dCBOR tree.
Sourcepub fn repeat(pattern: Pattern, quantifier: Quantifier) -> Pattern
pub fn repeat(pattern: Pattern, quantifier: Quantifier) -> Pattern
Creates a pattern that matches with repetition using a quantifier.
Sourcepub fn group(pattern: Pattern) -> Pattern
pub fn group(pattern: Pattern) -> Pattern
Creates a pattern that wraps another pattern (matches exactly once).
Source§impl Pattern
impl Pattern
Sourcepub fn any_tagged() -> Pattern
pub fn any_tagged() -> Pattern
Creates a pattern that matches any tagged value.
Sourcepub fn tagged(tag: impl Into<Tag>, pattern: Pattern) -> Pattern
pub fn tagged(tag: impl Into<Tag>, pattern: Pattern) -> Pattern
Creates a pattern that matches a tagged item with content pattern.
Sourcepub fn tagged_name(name: impl Into<String>, pattern: Pattern) -> Pattern
pub fn tagged_name(name: impl Into<String>, pattern: Pattern) -> Pattern
Creates a pattern that matches a tagged item with content pattern and a specific tag name.
Sourcepub fn tagged_regex(regex: Regex, pattern: Pattern) -> Pattern
pub fn tagged_regex(regex: Regex, pattern: Pattern) -> Pattern
Creates a pattern that matches a tagged item with content pattern and a regex for the tag name.
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