pub enum SubjectNameRef<'a> {
    DnsName(DnsNameRef<'a>),
    IpAddress(IpAddrRef<'a>),
}
Expand description

A DNS name or IP address, which borrows its text representation.

Variants§

§

DnsName(DnsNameRef<'a>)

A valid DNS name

§

IpAddress(IpAddrRef<'a>)

A valid IP address

Implementations§

source§

impl<'a> SubjectNameRef<'a>

source

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>.

source

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<'_>

source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<'a> Clone for SubjectNameRef<'a>

source§

fn clone(&self) -> SubjectNameRef<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for SubjectNameRef<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> From<DnsNameRef<'a>> for SubjectNameRef<'a>

source§

fn from(dns_name: DnsNameRef<'a>) -> SubjectNameRef<'_>

Converts to this type from the input type.
source§

impl<'a> From<IpAddrRef<'a>> for SubjectNameRef<'a>

source§

fn from(dns_name: IpAddrRef<'a>) -> SubjectNameRef<'_>

Converts to this type from the input type.
source§

impl<'a> Copy for SubjectNameRef<'a>

Auto Trait Implementations§

§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.