Trait DomainLabels
pub trait DomainLabels: Sealed {
type LabelIter<'a>: Iterator<Item = &'a Label> + DoubleEndedIterator + Clone
where Self: 'a;
// Required method
fn labels(&self) -> Self::LabelIter<'_>;
// Provided methods
fn label_count(&self) -> usize { ... }
fn starts_with<D>(&self, prefix: &D) -> bool
where D: DomainLabels + ?Sized { ... }
fn ends_with<D>(&self, suffix: &D) -> bool
where D: DomainLabels + ?Sized { ... }
fn is_subdomain_of<D>(&self, parent: &D) -> bool
where D: DomainLabels + ?Sized { ... }
fn parent(&self) -> Option<Domain> { ... }
fn suffix_iter(&self) -> SuffixIter<'_, Self> ⓘ
where Self: Sized { ... }
}net only.Expand description
Required Associated Types§
type LabelIter<'a>: Iterator<Item = &'a Label> + DoubleEndedIterator + Clone
where
Self: 'a
type LabelIter<'a>: Iterator<Item = &'a Label> + DoubleEndedIterator + Clone where Self: 'a
Iterator over the labels of self, yielded most-specific-first
("www.example.com".labels() yields www, example, com).
Required Methods§
Provided Methods§
fn label_count(&self) -> usize
fn label_count(&self) -> usize
Returns the number of labels.
fn starts_with<D>(&self, prefix: &D) -> boolwhere
D: DomainLabels + ?Sized,
fn starts_with<D>(&self, prefix: &D) -> boolwhere
D: DomainLabels + ?Sized,
Returns true if self’s labels start with prefix’s labels
(most-specific-end).
Note that starts_with operates on the left edge — the side closest to
the leaf. So "www.example.com".starts_with("www") is true.
fn ends_with<D>(&self, suffix: &D) -> boolwhere
D: DomainLabels + ?Sized,
fn ends_with<D>(&self, suffix: &D) -> boolwhere
D: DomainLabels + ?Sized,
Returns true if self’s labels end with suffix’s labels
(TLD-end).
"www.example.com".ends_with("example.com") is true.
fn is_subdomain_of<D>(&self, parent: &D) -> boolwhere
D: DomainLabels + ?Sized,
fn is_subdomain_of<D>(&self, parent: &D) -> boolwhere
D: DomainLabels + ?Sized,
Returns true if self is a subdomain of parent (or equal to it).
Returns false when parent has zero labels (e.g. an IP-valued
Host).
fn parent(&self) -> Option<Domain>
fn parent(&self) -> Option<Domain>
Returns the parent Domain (everything but the leftmost label), or
None if self has fewer than two labels.
fn suffix_iter(&self) -> SuffixIter<'_, Self> ⓘwhere
Self: Sized,
fn suffix_iter(&self) -> SuffixIter<'_, Self> ⓘwhere
Self: Sized,
Iterator over self and each successive parent, ending just before the
empty domain. For "a.b.c" yields "a.b.c", "b.c", "c".
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.