Enum ServerName
#[non_exhaustive]
pub 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 ServerName;
try_from.expect;
If you have an owned String, you can use TryFrom directly:
# use ServerName;
let name = "example.com".to_string;
try_from.expect;
which will yield a ServerName<'static> if successful.
or, alternatively...
# use ServerName;
let x: ServerName = "example.com".try_into.expect;
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) -> ServerName<'static>Produce an owned
ServerNamefrom this (potentially borrowed)ServerName.fn to_str(&self) -> Cow<'_, str>Return the string representation of this
ServerName.In the case of a
ServerName::DnsNameinstance, this function returns a borrowedstr. For aServerName::IpAddressinstance it returns an allocatedString.
Trait Implementations
impl Debug for ServerName<'_>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl From<IpAddr> for ServerName<'_>
fn from(addr: IpAddr) -> Self
impl From<IpAddr> for ServerName<'_>
fn from(addr: IpAddr) -> Self
impl From<Ipv4Addr> for ServerName<'_>
fn from(v4: Ipv4Addr) -> Self
impl From<Ipv4Addr> for ServerName<'_>
fn from(v4: Ipv4Addr) -> Self
impl From<Ipv6Addr> for ServerName<'_>
fn from(v6: Ipv6Addr) -> Self
impl From<Ipv6Addr> for ServerName<'_>
fn from(v6: Ipv6Addr) -> Self
impl TryFrom<String> for ServerName<'static>
type Error = InvalidDnsNameError;fn try_from(value: String) -> Result<Self, Self::Error>
impl<'a> Clone for ServerName<'a>
fn clone(&self) -> ServerName<'a>
impl<'a> Eq for ServerName<'a>
impl<'a> From<DnsName<'a>> for ServerName<'a>
fn from(dns_name: DnsName<'a>) -> Self
impl<'a> Hash for ServerName<'a>
fn hash<__H: Hasher>(&self, state: &mut __H)
impl<'a> PartialEq for ServerName<'a>
fn eq(&self, other: &ServerName<'a>) -> bool
impl<'a> StructuralPartialEq for ServerName<'a>
impl<'a> TryFrom<&'a [u8]> for ServerName<'a>
type Error = InvalidDnsNameError;fn try_from(value: &'a [u8]) -> Result<Self, Self::Error>
impl<'a> TryFrom<&'a str> for ServerName<'a>
type Error = InvalidDnsNameError;fn try_from(s: &'a str) -> Result<Self, Self::Error>
Auto Trait Implementations
impl<'a> Freeze for ServerName<'a>
impl<'a> RefUnwindSafe for ServerName<'a>
impl<'a> Send for ServerName<'a>
impl<'a> Sync for ServerName<'a>
impl<'a> Unpin for ServerName<'a>
impl<'a> UnsafeUnpin for ServerName<'a>
impl<'a> UnwindSafe for ServerName<'a>
Blanket Implementations
impl<T> Any for ServerName<'a>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for ServerName<'a>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for ServerName<'a>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for ServerName<'a>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for ServerName<'a>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for ServerName<'a>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for ServerName<'a>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for ServerName<'a>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for ServerName<'a>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>