Enum specifications::address::Address

source ·
pub enum Address {
    Ipv4(Ipv4Addr, u16),
    Ipv6(Ipv6Addr, u16),
    Hostname(String, u16),
}
Expand description

Defines a more lenient alternative to a SocketAddr that also accepts hostnames.

Variants§

§

Ipv4(Ipv4Addr, u16)

It’s an Ipv4 address.

§

Ipv6(Ipv6Addr, u16)

It’s an Ipv6 address.

§

Hostname(String, u16)

It’s a hostname.

Implementations§

source§

impl Address

source

pub fn ipv4(b1: u8, b2: u8, b3: u8, b4: u8, port: u16) -> Self

Constructor for the Address that initializes it for the given IPv4 address.

§Arguments
  • b1: The first byte of the IPv4 address.
  • b2: The second byte of the IPv4 address.
  • b3: The third byte of the IPv4 address.
  • b4: The fourth byte of the IPv4 address.
  • port: The port for this address.
§Returns

A new Address instance.

source

pub fn from_ipv4(ipv4: impl Into<Ipv4Addr>, port: u16) -> Self

Constructor for the Address that initializes it for the given IPv4 address.

§Arguments
  • ipv4: The already constructed IPv4 address to use.
  • port: The port for this address.
§Returns

A new Address instance.

source

pub fn ipv6( b1: u16, b2: u16, b3: u16, b4: u16, b5: u16, b6: u16, b7: u16, b8: u16, port: u16, ) -> Self

Constructor for the Address that initializes it for the given IPv6 address.

§Arguments
  • b1: The first pair of bytes of the IPv6 address.
  • b2: The second pair of bytes of the IPv6 address.
  • b3: The third pair of bytes of the IPv6 address.
  • b4: The fourth pair of bytes of the IPv6 address.
  • b5: The fifth pair of bytes of the IPv6 address.
  • b6: The sixth pair of bytes of the IPv6 address.
  • b7: The seventh pair of bytes of the IPv6 address.
  • b8: The eight pair of bytes of the IPv6 address.
  • port: The port for this address.
§Returns

A new Address instance.

source

pub fn from_ipv6(ipv6: impl Into<Ipv6Addr>, port: u16) -> Self

Constructor for the Address that initializes it for the given IPv6 address.

§Arguments
  • ipv6: The already constructed IPv6 address to use.
  • port: The port for this address.
§Returns

A new Address instance.

source

pub fn hostname(hostname: impl Into<String>, port: u16) -> Self

Constructor for the Address that initializes it for the given hostname.

§Arguments
  • hostname: The hostname for this Address.
  • port: The port for this address.
§Returns

A new Address instance.

source

pub fn domain(&self) -> Cow<'_, str>

Returns the domain-part, as a (serialized) string version.

§Returns

A Cow<str> that either contains a reference to the already String hostname, or else a newly created string that is the serialized version of an IP.

source

pub fn port(&self) -> u16

Returns the port-part, as a number.

§Returns

A u16 that is the port.

source

pub fn port_mut(&mut self) -> &mut u16

Returns the port-part as a mutable number.

§Returns

A mutable reference to the u16 that is the port.

source

pub fn is_hostname(&self) -> bool

Returns if this Address is an Address::Hostname.

§Returns

True if it is, false if it isn’t.

source

pub fn is_ip(&self) -> bool

Returns if this Address is an Address::Ipv4 or Address::Ipv6.

§Returns

True if it is, false if it isn’t.

source

pub fn is_ipv4(&self) -> bool

Returns if this Address is an Address::Ipv4.

§Returns

True if it is, false if it isn’t.

source

pub fn is_ipv6(&self) -> bool

Returns if this Address is an Address::Ipv6.

§Returns

True if it is, false if it isn’t.

source

pub fn serialize(&self) -> impl '_ + Display

Returns a formatter that deterministically and parseably serializes the Address.

Trait Implementations§

source§

impl AsRef<Address> for Address

source§

fn as_ref(&self) -> &Self

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

impl Clone for Address

source§

fn clone(&self) -> Address

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 Debug for Address

source§

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

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

impl<'de> Deserialize<'de> for Address

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Address

source§

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

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

impl EnumDebug for Address

source§

fn type_name() -> &'static str

Returns the static name of the type used for EnumDebug-printing. Read more
source§

fn variant_names() -> &'static [&'static str]

Returns all variants in the trait as a list of names. Read more
source§

fn variant_name(&self) -> &'static str

Returns the static name of the variant. Read more
source§

fn variant(&self) -> EnumDebugFormatter<'_, Self>

Returns a formatter for this enum that writes its variant name. Read more
source§

fn variants() -> Copied<Iter<'static, &'static str>>

Returns an iterator over all variants in this enum. Read more
source§

impl From<&Address> for Address

source§

fn from(value: &Address) -> Self

Converts to this type from the input type.
source§

impl From<&mut Address> for Address

source§

fn from(value: &mut Address) -> Self

Converts to this type from the input type.
source§

impl From<Address> for AddressOpt

source§

fn from(value: Address) -> Self

Converts to this type from the input type.
source§

impl FromStr for Address

source§

type Err = AddressError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Serialize for Address

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl TryFrom<AddressOpt> for Address

source§

type Error = AddressError

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

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

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromRef<T> for T
where T: Clone,

source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where 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> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> ToOwned for T
where T: Clone,

source§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

source§

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 T
where U: TryFrom<T>,

source§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T