Skip to main content

PathPattern

Trait PathPattern 

Source
pub trait PathPattern {
    // Required methods
    fn is_supported_by<I, S>(&self, patterns: I) -> bool
       where I: IntoIterator<Item = S>,
             S: AsRef<str>;
    fn is_a_path_match_with(&self, path: &str) -> bool;
}
Expand description

Matches dotted paths against patterns.

A pattern segment of * matches exactly one path segment. contacts.*.info.name matches contacts.0.info.name and does not match contacts.0.info.name.last.

These methods correspond to IsSupportedBy and IsAPathMatchWith. Call PathPattern::is_supported_by on a path, and PathPattern::is_a_path_match_with on a pattern.

Required Methods§

Source

fn is_supported_by<I, S>(&self, patterns: I) -> bool
where I: IntoIterator<Item = S>, S: AsRef<str>,

true when this path matches any of patterns.

§Examples
use json_traits::PathPattern;

let patterns = ["prop1.prop2", "contacts.*.info.name", "contacts.*.info.number"];
assert!("contacts.0.info.name".is_supported_by(patterns));
assert!(!"contacts.0.info.name.last".is_supported_by(patterns));
Source

fn is_a_path_match_with(&self, path: &str) -> bool

true when this pattern matches path.

The receiver is the pattern: "contacts.*.name".is_a_path_match_with("contacts.0.name").

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl PathPattern for str

Source§

fn is_supported_by<I, S>(&self, patterns: I) -> bool
where I: IntoIterator<Item = S>, S: AsRef<str>,

Source§

fn is_a_path_match_with(&self, path: &str) -> bool

Implementors§