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
impl Address
sourcepub fn ipv4(b1: u8, b2: u8, b3: u8, b4: u8, port: u16) -> Self
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.
sourcepub fn ipv6(
b1: u16,
b2: u16,
b3: u16,
b4: u16,
b5: u16,
b6: u16,
b7: u16,
b8: u16,
port: u16,
) -> Self
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.
sourcepub fn domain(&self) -> Cow<'_, str>
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.
sourcepub fn port_mut(&mut self) -> &mut u16
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.
sourcepub fn is_hostname(&self) -> bool
pub fn is_hostname(&self) -> bool
sourcepub fn is_ip(&self) -> bool
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.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Address
impl<'de> Deserialize<'de> for Address
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
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 EnumDebug for Address
impl EnumDebug for Address
source§fn type_name() -> &'static str
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]
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
fn variant_name(&self) -> &'static str
Returns the static name of the variant. Read more
source§fn variant(&self) -> EnumDebugFormatter<'_, Self>
fn variant(&self) -> EnumDebugFormatter<'_, Self>
Returns a formatter for this enum that writes its variant name. Read more
source§impl From<Address> for AddressOpt
impl From<Address> for AddressOpt
source§impl TryFrom<AddressOpt> for Address
impl TryFrom<AddressOpt> for Address
source§type Error = AddressError
type Error = AddressError
The type returned in the event of a conversion error.
Auto Trait Implementations§
impl Freeze for Address
impl RefUnwindSafe for Address
impl Send for Address
impl Sync for Address
impl Unpin for Address
impl UnwindSafe for Address
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
Mutably borrows from an owned value. Read more
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)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request