pub struct DomainName(/* private fields */);Expand description
Canonical DNS name used in network policy rules.
Strictly a hostname — port suffixes, userinfo, schemes, paths, queries, and fragments are rejected at parse time so a rule can never end up “matching” a name no DNS responder will ever return.
Constructed via str::parse or TryFrom<String>; both route through
the same validation and canonicalization. The inner form is
lowercased ASCII with no leading or trailing dots — the same form
the DNS interceptor stores on the resolved-hostname cache, which
lets match-time comparisons be byte-equal rather than
case-insensitive.
Implementations§
Source§impl DomainName
impl DomainName
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Borrow the canonical string form. The returned slice has no trailing dot and is lowercased ASCII.
Sourcepub fn try_into_suffix(self) -> Result<Self, DomainNameError>
pub fn try_into_suffix(self) -> Result<Self, DomainNameError>
Validate this name for use as a Destination::DomainSuffix
target and return it unchanged on success.
Returns DomainNameError::SuffixTooBroad when the name is a
single DNS label (e.g. com, local, internal). The
label-aware suffix matcher would otherwise treat such a name
as “match every host under that TLD” which is almost certainly
not what the operator meant. Use a multi-label suffix
(myco.com, corp.internal) instead.
Domains intended for exact-match rules are unaffected: use
Destination::Domain for those.
Trait Implementations§
Source§impl Clone for DomainName
impl Clone for DomainName
Source§fn clone(&self) -> DomainName
fn clone(&self) -> DomainName
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DomainName
impl Debug for DomainName
Source§impl<'de> Deserialize<'de> for DomainName
impl<'de> Deserialize<'de> for DomainName
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for DomainName
impl Display for DomainName
Source§impl From<DomainName> for String
impl From<DomainName> for String
Source§fn from(name: DomainName) -> Self
fn from(name: DomainName) -> Self
Source§impl FromStr for DomainName
impl FromStr for DomainName
Source§impl Hash for DomainName
impl Hash for DomainName
Source§impl PartialEq for DomainName
impl PartialEq for DomainName
Source§fn eq(&self, other: &DomainName) -> bool
fn eq(&self, other: &DomainName) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for DomainName
impl Serialize for DomainName
Source§impl TryFrom<&str> for DomainName
impl TryFrom<&str> for DomainName
Source§impl TryFrom<String> for DomainName
impl TryFrom<String> for DomainName
impl Eq for DomainName
impl StructuralPartialEq for DomainName
Auto Trait Implementations§
impl Freeze for DomainName
impl RefUnwindSafe for DomainName
impl Send for DomainName
impl Sync for DomainName
impl Unpin for DomainName
impl UnsafeUnpin for DomainName
impl UnwindSafe for DomainName
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§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,
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.