pub struct Prefix { /* private fields */ }Expand description
One member of a grant: a path, covering itself and every path beneath it.
The empty prefix covers every path. A prefix is spelled like a path: /-separated
segments, a \ escaping the \ or / after it, at most Path::MAX_PARTS
segments, and no leading, trailing, or doubled /. It never holds a *: parsing one
fails loudly with InvalidPrefix::Wildcard, since a grant never names a wildcard.
Ordered segment by segment, so a prefix sorts right before every path beneath it.
Implementations§
Source§impl Prefix
impl Prefix
Sourcepub fn matches(&self, path: &str) -> bool
pub fn matches(&self, path: &str) -> bool
Whether path is this prefix or beneath it. The path is normalized like a broadcast
path (slashes trimmed and collapsed).
Sourcepub fn overlaps(&self, path: &str) -> bool
pub fn overlaps(&self, path: &str) -> bool
Whether this prefix covers some path at or beneath path: one lies beneath the other.
The path is normalized like a broadcast path.
Sourcepub fn rooted(&self, root: &str) -> Result<Self, InvalidPrefix>
pub fn rooted(&self, root: &str) -> Result<Self, InvalidPrefix>
This prefix placed beneath the path root, normalized like a broadcast path (slashes
trimmed and collapsed). Fails when root holds a wildcard or a malformed escape, or
the result has too many segments.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Prefix
impl<'de> Deserialize<'de> for Prefix
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl Eq for Prefix
Source§impl Extend<Prefix> for Prefixes
impl Extend<Prefix> for Prefixes
Source§fn extend<I: IntoIterator<Item = Prefix>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Prefix>>(&mut self, iter: I)
Reduce the members and the new prefixes together, in one pass.
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl FromIterator<Prefix> for Prefixes
impl FromIterator<Prefix> for Prefixes
Source§fn from_iter<I: IntoIterator<Item = Prefix>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = Prefix>>(iter: I) -> Self
Reduce in one sort and one sweep: a member’s subtree sorts right after it, so each prefix is beneath a member kept already only if it is beneath the last one kept.
Source§impl FromStr for Prefix
impl FromStr for Prefix
Source§fn from_str(text: &str) -> Result<Self, InvalidPrefix>
fn from_str(text: &str) -> Result<Self, InvalidPrefix>
Parse a prefix’s text. A * anywhere is refused before anything else, so a wildcard
written where a prefix belongs always says so. Slashes are not normalized: a
leading, trailing, or doubled / is an error, so a typo cannot silently widen a grant.
Source§type Err = InvalidPrefix
type Err = InvalidPrefix
Source§impl Ord for Prefix
impl Ord for Prefix
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Prefix
impl PartialOrd for Prefix
impl StructuralPartialEq for Prefix
Auto Trait Implementations§
impl Freeze for Prefix
impl RefUnwindSafe for Prefix
impl Send for Prefix
impl Sync for Prefix
impl Unpin for Prefix
impl UnsafeUnpin for Prefix
impl UnwindSafe for Prefix
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.