Enum webpki::SubjectNameRef
source · pub enum SubjectNameRef<'a> {
DnsName(DnsNameRef<'a>),
IpAddress(IpAddrRef<'a>),
}
Expand description
A DNS name or IP address, which borrows its text representation.
Variants§
Implementations§
source§impl<'a> SubjectNameRef<'a>
impl<'a> SubjectNameRef<'a>
sourcepub fn try_from_ascii(
subject_name: &'a [u8],
) -> Result<Self, InvalidSubjectNameError>
pub fn try_from_ascii( subject_name: &'a [u8], ) -> Result<Self, InvalidSubjectNameError>
Attempts to decode an encodingless string as either an IPv4 address, IPv6 address or DNS name; in that order. In practice this space is non-overlapping because DNS name components are separated by periods but cannot be wholly numeric (so cannot overlap with a valid IPv4 address), and IPv6 addresses are separated by colons but cannot contain periods.
The IPv6 address encoding supported here is extremely simplified; it does not support
compression, all leading zeroes must be present in each 16-bit word, etc. Generally
this is not suitable as a parse for human-provided addresses for this reason. Instead:
consider parsing these with std::net::IpAddr
and then using
IpAddr::from<std::net::IpAddr>
.
sourcepub fn try_from_ascii_str(
subject_name: &'a str,
) -> Result<Self, InvalidSubjectNameError>
pub fn try_from_ascii_str( subject_name: &'a str, ) -> Result<Self, InvalidSubjectNameError>
Constructs a SubjectNameRef
from the given input if the
input is a syntactically-valid DNS name or IP address.
Trait Implementations§
source§impl AsRef<[u8]> for SubjectNameRef<'_>
impl AsRef<[u8]> for SubjectNameRef<'_>
source§impl<'a> Clone for SubjectNameRef<'a>
impl<'a> Clone for SubjectNameRef<'a>
source§fn clone(&self) -> SubjectNameRef<'a>
fn clone(&self) -> SubjectNameRef<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more