pub struct MB<'a>(pub Name<'a>);Expand description
Mailbox domain name (EXPERIMENTAL), RFC 1035
Tuple Fields§
§0: Name<'a>Implementations§
Methods from Deref<Target = Name<'a>>§
Sourcepub fn is_link_local(&self) -> bool
pub fn is_link_local(&self) -> bool
Verify if name ends with .local.
Sourcepub fn is_subdomain_of(&self, other: &Name<'_>) -> bool
pub fn is_subdomain_of(&self, other: &Name<'_>) -> bool
Returns true if self is a subdomain of other
Sourcepub fn without(&self, domain: &Name<'_>) -> Option<Name<'_>>
pub fn without(&self, domain: &Name<'_>) -> Option<Name<'_>>
Returns the subdomain part of self, based on domain.
If self is not a subdomain of domain, returns None
Example:
let name = Name::new_unchecked("sub.domain.local");
let domain = Name::new_unchecked("domain.local");
assert!(domain.without(&name).is_none());
let sub = name.without(&domain).unwrap();
assert_eq!(sub.to_string(), "sub")Sourcepub fn get_labels(&self) -> &[Label<'a>]
pub fn get_labels(&self) -> &[Label<'a>]
Get the labels that compose this name
Sourcepub fn is_valid_hostname(&self) -> bool
pub fn is_valid_hostname(&self) -> bool
Returns true if the name has at least one label and every label is a valid host name
label, see Label::is_valid_hostname.
assert!(Name::new_unchecked("my-host.example.com").is_valid_hostname());
assert!(!Name::new_unchecked("_srv.example.com").is_valid_hostname());
assert!(!Name::new_unchecked(".").is_valid_hostname());Sourcepub fn is_valid_sub_type_name(&self) -> bool
pub fn is_valid_sub_type_name(&self) -> bool
Returns true if the name is a DNS-SD subtype name:
<Subtype>._sub.<sn>._tcp|_udp.<domain> (RFC 6763 section 7.1).
The subtype can be any label (see Label::is_valid_instance_label) and does not need to
start with an underscore. The rest of the name must be a valid service name, see
Name::is_valid_service_name.
assert!(Name::new_unchecked("_printer._sub._http._tcp.local").is_valid_sub_type_name());
assert!(Name::new_unchecked("The Music Store._sub._http._tcp.local").is_valid_sub_type_name());
assert!(!Name::new_unchecked("_printer._http._tcp.local").is_valid_sub_type_name());Sourcepub fn is_valid_instance_name(&self) -> bool
pub fn is_valid_instance_name(&self) -> bool
Returns true if the name is a DNS-SD service instance name:
<Instance>.<sn>._tcp|_udp.<domain> (RFC 6763 section 4.3).
The instance can be any label (see Label::is_valid_instance_label), including one that
contains dots. The rest of the name must be a valid service name, see
Name::is_valid_service_name.
assert!(Name::new_unchecked("My Printer._ipp._tcp.local").is_valid_instance_name());
// the escaped dot keeps `My. Printer` as a single label
assert!(Name::new(r"My\. Printer._ipp._tcp.local").unwrap().is_valid_instance_name());
assert!(!Name::new_unchecked("My Printer._ipp._ftp.local").is_valid_instance_name());Sourcepub fn is_valid_service_name(&self) -> bool
pub fn is_valid_service_name(&self) -> bool
Returns true if the name is a DNS-SD service name: <sn>._tcp|_udp.<domain>
(RFC 6763 sections 4.1.2 and 7).
- the first label must pass
Label::is_valid_service_label - the second label must be
_tcpor_udp, ignoring case - the remaining domain labels must pass
Label::is_valid_hostname
This is a syntax check. It does not check that the service is registered.
assert!(Name::new_unchecked("_http._tcp.local").is_valid_service_name());
assert!(!Name::new_unchecked("http._tcp.local").is_valid_service_name());
assert!(!Name::new_unchecked("_http._ftp.local").is_valid_service_name());