Struct DomainTrie
pub struct DomainTrie<T> { /* private fields */ }
Expand description
An efficient radix tree that can be used to match (sub)domains.
Implementations§
§impl<T> DomainTrie<T>
impl<T> DomainTrie<T>
pub fn new() -> DomainTrie<T>
pub fn new() -> DomainTrie<T>
Create a new DomainTrie
.
pub fn with_insert_domain(
self,
domain: impl AsRef<str>,
value: T,
) -> DomainTrie<T>
pub fn with_insert_domain( self, domain: impl AsRef<str>, value: T, ) -> DomainTrie<T>
Consume self
and insert the given domain paired with the input value T
.
This overwrites any existing value already in the tree for that (trie) node.
pub fn insert_domain(
&mut self,
domain: impl AsRef<str>,
value: T,
) -> &mut DomainTrie<T>
pub fn insert_domain( &mut self, domain: impl AsRef<str>, value: T, ) -> &mut DomainTrie<T>
Insert the given domain paired with the input value T
.
This overwrites any existing value already in the tree for that (trie) node.
pub fn with_insert_domain_iter<I, S>(
self,
domains: I,
value: T,
) -> DomainTrie<T>
pub fn with_insert_domain_iter<I, S>( self, domains: I, value: T, ) -> DomainTrie<T>
Consume self
and insert the given domains paired with the input value T
.
This overwrites any existing value already in the tree for that (trie) node.
pub fn insert_domain_iter<I, S>(
&mut self,
domains: I,
value: T,
) -> &mut DomainTrie<T>
pub fn insert_domain_iter<I, S>( &mut self, domains: I, value: T, ) -> &mut DomainTrie<T>
Insert the given domains paired with the input value T
.
This overwrites any existing value already in the tree for that (trie) node.
pub fn extend<I, S>(&mut self, iter: I) -> &mut DomainTrie<T>
pub fn extend<I, S>(&mut self, iter: I) -> &mut DomainTrie<T>
Extend this DomainTrie
with the given pairs.
pub fn is_match_parent(&self, domain: impl AsRef<str>) -> bool
pub fn is_match_parent(&self, domain: impl AsRef<str>) -> bool
Returns true if the input domain is a subdomain of
at least one node found in this DomainTrie
.
pub fn match_parent(&self, domain: impl AsRef<str>) -> Option<&T>
pub fn match_parent(&self, domain: impl AsRef<str>) -> Option<&T>
Returns the value for the most specific node found in the DomainTrie
which is the exact domain or parent domain for a domain in this trie.
Use Self::match_exact
(first) in case you prefer an exact match instead.
pub fn is_match_exact(&self, domain: impl AsRef<str>) -> bool
pub fn is_match_exact(&self, domain: impl AsRef<str>) -> bool
Returns true if the input domain is an exact domain
stored in this DomainTrie
.
pub fn match_exact(&self, domain: impl AsRef<str>) -> Option<&T>
pub fn match_exact(&self, domain: impl AsRef<str>) -> Option<&T>
Returns the value that is stored for a given exact domain as stored in this trie.
Trait Implementations§
§impl<T> Clone for DomainTrie<T>where
T: Clone,
impl<T> Clone for DomainTrie<T>where
T: Clone,
§fn clone(&self) -> DomainTrie<T>
fn clone(&self) -> DomainTrie<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl<T> Debug for DomainTrie<T>where
T: Debug,
impl<T> Debug for DomainTrie<T>where
T: Debug,
§impl<T> Default for DomainTrie<T>
impl<T> Default for DomainTrie<T>
§fn default() -> DomainTrie<T>
fn default() -> DomainTrie<T>
§impl<S, T> FromIterator<(S, T)> for DomainTrie<T>
impl<S, T> FromIterator<(S, T)> for DomainTrie<T>
§fn from_iter<I>(iter: I) -> DomainTrie<T>where
I: IntoIterator<Item = (S, T)>,
fn from_iter<I>(iter: I) -> DomainTrie<T>where
I: IntoIterator<Item = (S, T)>,
Auto Trait Implementations§
impl<T> Freeze for DomainTrie<T>
impl<T> RefUnwindSafe for DomainTrie<T>where
T: RefUnwindSafe,
impl<T> Send for DomainTrie<T>where
T: Send,
impl<T> Sync for DomainTrie<T>where
T: Sync,
impl<T> Unpin for DomainTrie<T>
impl<T> UnwindSafe for DomainTrie<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more