pub struct FQDN(_);Expand description
A FQDN string.
The inner byte sequence is conformed with the RFC-1035: each label of the FQDN is prefixed by a length byte and the sequence is nul-terminated.
For instance, the FQDN github.com. is exactly represented as b"\x06github\x03com\x00".
FQDN is to &Fqdn as String is to &str: the former
in each pair are owned data; the latter are borrowed references.
Methods from Deref<Target = Fqdn>
sourcepub fn is_root(&self) -> bool
pub fn is_root(&self) -> bool
Checks if this is the top domain.
The human-readable representation of the top domain is the single dot ..
sourcepub fn is_subdomain_of(&self, parent: &Fqdn) -> bool
pub fn is_subdomain_of(&self, parent: &Fqdn) -> bool
Checks if this domain is an descendant of another one.
Example
assert![ fqdn!("github.com.").is_subdomain_of(&fqdn!("github.com.")) ];
assert![ fqdn!("www.rust-lang.github.com").is_subdomain_of(&fqdn!("github.com.")) ];
assert![ ! fqdn!("github.com.").is_subdomain_of(&fqdn!("www.rust-lang.github.com")) ];sourcepub fn tld(&self) -> Option<&Fqdn>
pub fn tld(&self) -> Option<&Fqdn>
Gets the top level domain.
The TLD is the last part of a FQDN.
For instance, the TLD of rust-lang.github.io. is io.
If the FQDN is already a TLD, self is returned.
If the FQDN is the top domain, None is returned.
Example
assert_eq![ fqdn!("rust-lang.github.com.").tld(), Some(fqdn!("com.").as_ref()) ];
assert_eq![ fqdn!(".").tld(), None ];sourcepub fn parent(&self) -> Option<&Fqdn>
pub fn parent(&self) -> Option<&Fqdn>
Extracts a Fqdn slice with contains the immediate parent domain.
The parent is the domain after remaining the first label.
If it is already the top domain, then None is returned.
To iterate over the hierarchy of a FQDN, consider Self::hierarchy
Example
assert_eq![ fqdn!("github.com").parent(), Some(fqdn!("com").as_ref()) ];
assert_eq![ fqdn!("github.com").parent().unwrap().parent(), None ];
assert_eq![ fqdn!(".").parent(), None ];sourcepub fn hierarchy(&self) -> impl '_ + Iterator<Item = &Fqdn>
pub fn hierarchy(&self) -> impl '_ + Iterator<Item = &Fqdn>
Iterates over the parents of the FQDN.
Example
let fqdn = fqdn!("rust-lang.github.com.");
let mut iter = fqdn.hierarchy();
assert_eq![ iter.next(), Some(fqdn!("rust-lang.github.com.").as_ref()) ];
assert_eq![ iter.next(), Some(fqdn!("github.com.").as_ref()) ];
assert_eq![ iter.next(), Some(fqdn!("com.").as_ref()) ];
assert_eq![ iter.next(), None ];sourcepub fn depth(&self) -> usize
pub fn depth(&self) -> usize
Computes the depth of this domain (i.e. counts the labels)
Example
assert_eq![ fqdn!("rust-lang.github.com.").depth(), 3 ];
assert_eq![ fqdn!("github.com.").depth(), 2 ];
assert_eq![ fqdn!(".").depth(), 0 ];sourcepub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &mut [u8]
pub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &mut [u8]
Returns the complete byte sequence of the FQDN.
The returned sequence is terminated by the nul byte.
Example
assert_eq![ fqdn!("crates.io.").as_bytes(), b"\x06crates\x02io\x00" ];sourcepub fn labels(&self) -> impl '_ + Iterator<Item = &str>
pub fn labels(&self) -> impl '_ + Iterator<Item = &str>
Iterates over the labels which constitutes the FQDN.
Example
let fqdn = fqdn!("rust-lang.github.com.");
let mut iter = fqdn.labels();
assert_eq![ iter.next(), Some("rust-lang") ];
assert_eq![ iter.next(), Some("github") ];
assert_eq![ iter.next(), Some("com") ];
assert_eq![ iter.next(), None ];Trait Implementations
impl Eq for FQDN
impl StructuralEq for FQDN
Auto Trait Implementations
impl RefUnwindSafe for FQDN
impl Send for FQDN
impl Sync for FQDN
impl Unpin for FQDN
impl UnwindSafe for FQDN
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more