Enum ServerName

enum ServerName<'a>

Encodes ways a client can know the expected name of the server.

This currently covers knowing the DNS name of the server, but will be extended in the future to supporting privacy-preserving names for the server ("ECH"). For this reason this enum is non_exhaustive.

Making one

If you have a DNS name as a &str, this type implements TryFrom<&str>, so you can do:

# use rustls_pki_types::ServerName;
ServerName::try_from("example.com").expect("invalid DNS name");

If you have an owned String, you can use TryFrom directly:

# use rustls_pki_types::ServerName;
let name = "example.com".to_string();
#[cfg(feature = "alloc")]
ServerName::try_from(name).expect("invalid DNS name");

which will yield a ServerName<'static> if successful.

or, alternatively...

# use rustls_pki_types::ServerName;
let x: ServerName = "example.com".try_into().expect("invalid DNS name");

Variants

DnsName(DnsName<'a>)

The server is identified by a DNS name. The name is sent in the TLS Server Name Indication (SNI) extension.

IpAddress(IpAddr)

The server is identified by an IP address. SNI is not done.

Implementations

impl ServerName<'_>

fn to_owned(self: &Self) -> ServerName<'static>

Produce an owned ServerName from this (potentially borrowed) ServerName.

fn to_str(self: &Self) -> Cow<'_, str>

Return the string representation of this ServerName.

In the case of a ServerName::DnsName instance, this function returns a borrowed str. For a ServerName::IpAddress instance it returns an allocated String.

impl Debug for ServerName<'_>

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

impl From for ServerName<'_>

fn from(addr: IpAddr) -> Self

impl From for ServerName<'_>

fn from(v6: Ipv6Addr) -> Self

impl From for ServerName<'_>

fn from(v4: Ipv4Addr) -> Self

impl From for ServerName<'_>

fn from(v6: Ipv6Addr) -> Self

impl From for ServerName<'_>

fn from(addr: IpAddr) -> Self

impl From for ServerName<'_>

fn from(v4: Ipv4Addr) -> Self

impl TryFrom for ServerName<'static>

fn try_from(value: String) -> Result<Self, <Self as >::Error>

impl<'a> Clone for ServerName<'a>

fn clone(self: &Self) -> ServerName<'a>

impl<'a> Eq for ServerName<'a>

impl<'a> Freeze for ServerName<'a>

impl<'a> Hash for ServerName<'a>

fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)

impl<'a> PartialEq for ServerName<'a>

fn eq(self: &Self, other: &ServerName<'a>) -> bool

impl<'a> RefUnwindSafe for ServerName<'a>

impl<'a> Send for ServerName<'a>

impl<'a> StructuralPartialEq for ServerName<'a>

impl<'a> Sync for ServerName<'a>

impl<'a> TryFrom for ServerName<'a>

fn try_from(s: &'a str) -> Result<Self, <Self as >::Error>

impl<'a> TryFrom for ServerName<'a>

fn try_from(value: &'a [u8]) -> Result<Self, <Self as >::Error>

impl<'a> Unpin for ServerName<'a>

impl<'a> UnwindSafe for ServerName<'a>

impl<T> Any for ServerName<'a>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for ServerName<'a>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for ServerName<'a>

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

impl<T> CloneToUninit for ServerName<'a>

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for ServerName<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for ServerName<'a>

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for ServerName<'a>

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for ServerName<'a>

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

impl<T, U> TryInto for ServerName<'a>

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