Enum webpki::subject_name::name::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 moresource§impl<'a> Debug for SubjectNameRef<'a>
impl<'a> Debug for SubjectNameRef<'a>
source§impl<'a> From<DnsNameRef<'a>> for SubjectNameRef<'a>
impl<'a> From<DnsNameRef<'a>> for SubjectNameRef<'a>
source§fn from(dns_name: DnsNameRef<'a>) -> SubjectNameRef<'_>
fn from(dns_name: DnsNameRef<'a>) -> SubjectNameRef<'_>
source§impl<'a> From<IpAddrRef<'a>> for SubjectNameRef<'a>
impl<'a> From<IpAddrRef<'a>> for SubjectNameRef<'a>
source§fn from(dns_name: IpAddrRef<'a>) -> SubjectNameRef<'_>
fn from(dns_name: IpAddrRef<'a>) -> SubjectNameRef<'_>
impl<'a> Copy for SubjectNameRef<'a>
Auto Trait Implementations§
impl<'a> Freeze for SubjectNameRef<'a>
impl<'a> RefUnwindSafe for SubjectNameRef<'a>
impl<'a> Send for SubjectNameRef<'a>
impl<'a> Sync for SubjectNameRef<'a>
impl<'a> Unpin for SubjectNameRef<'a>
impl<'a> UnwindSafe for SubjectNameRef<'a>
Blanket Implementations§
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)