pub struct Prefixes(/* private fields */);Expand description
A grant: a set of prefixes, reduced so no member lies beneath another.
Order is canonical (see Prefix), so two sets covering the same paths compare equal.
The empty set grants nothing; all grants everything.
Every operation costs near-linear time in the members it reads: collecting sorts once
and sweeps, and a query binary-searches each prefix above the path it asks about, of
which there are at most Path::MAX_PARTS + 1. So a peer’s grant costs
O(n log n) to read, whatever its shape.
Implementations§
Source§impl Prefixes
impl Prefixes
Sourcepub fn insert(&mut self, prefix: Prefix) -> bool
pub fn insert(&mut self, prefix: Prefix) -> bool
Add a prefix, dropping the members beneath it. Returns false when a member already
covers it, leaving the set unchanged.
Sourcepub fn matches(&self, path: &str) -> bool
pub fn matches(&self, path: &str) -> bool
Whether some member covers path, normalized like a broadcast path.
Sourcepub fn covers(&self, other: &Self) -> bool
pub fn covers(&self, other: &Self) -> bool
Whether every member of other is covered here: other grants nothing this set
does not. The empty set is covered by anything.
Sourcepub fn overlaps(&self, path: &str) -> bool
pub fn overlaps(&self, path: &str) -> bool
Whether some member covers a path at or beneath path, normalized like a broadcast
path.
Sourcepub fn intersect(&self, other: &Self) -> Self
pub fn intersect(&self, other: &Self) -> Self
The paths both sets grant. Each member of the result is a member of one side lying within the other, so it never grows past both sets together.
Sourcepub fn rebase(&self, root: &str) -> Self
pub fn rebase(&self, root: &str) -> Self
Every member as seen from the path root; see Prefix::rebase.
Sourcepub fn rooted(&self, root: &str) -> Result<Self, InvalidPrefix>
pub fn rooted(&self, root: &str) -> Result<Self, InvalidPrefix>
Every member placed beneath the path root; see Prefix::rooted.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Prefixes
impl<'de> Deserialize<'de> for Prefixes
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Reads a list and reduces it, so a persisted grant is canonical after a round trip.
impl Eq for Prefixes
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 IntoIterator for Prefixes
impl IntoIterator for Prefixes
Source§impl<'a> IntoIterator for &'a Prefixes
impl<'a> IntoIterator for &'a Prefixes
impl StructuralPartialEq for Prefixes
Auto Trait Implementations§
impl Freeze for Prefixes
impl RefUnwindSafe for Prefixes
impl Send for Prefixes
impl Sync for Prefixes
impl Unpin for Prefixes
impl UnsafeUnpin for Prefixes
impl UnwindSafe for Prefixes
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,
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.