Enum specifications::address::AddressOpt
source · pub enum AddressOpt {
Ipv4(Ipv4Addr, Option<u16>),
Ipv6(Ipv6Addr, Option<u16>),
Hostname(String, Option<u16>),
}
Expand description
Alternative to an Address
that has an optional port part.
Variants§
Ipv4(Ipv4Addr, Option<u16>)
It’s an Ipv4 address.
Ipv6(Ipv6Addr, Option<u16>)
It’s an Ipv6 address.
Hostname(String, Option<u16>)
It’s a hostname.
Implementations§
source§impl AddressOpt
impl AddressOpt
sourcepub fn ipv4(b1: u8, b2: u8, b3: u8, b4: u8, port: Option<u16>) -> Self
pub fn ipv4(b1: u8, b2: u8, b3: u8, b4: u8, port: Option<u16>) -> Self
Constructor for the AddressOpt 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, if any.
§Returns
A new AddressOpt instance.
sourcepub fn ipv6(
b1: u16,
b2: u16,
b3: u16,
b4: u16,
b5: u16,
b6: u16,
b7: u16,
b8: u16,
port: Option<u16>,
) -> Self
pub fn ipv6( b1: u16, b2: u16, b3: u16, b4: u16, b5: u16, b6: u16, b7: u16, b8: u16, port: Option<u16>, ) -> Self
Constructor for the AddressOpt 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, if any.
§Returns
A new AddressOpt 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 Option<u16>
pub fn port_mut(&mut self) -> &mut Option<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 AddressOpt is an AddressOpt::Ipv4
or AddressOpt::Ipv6
.
§Returns
True if it is, false if it isn’t.
Trait Implementations§
source§impl AsRef<AddressOpt> for AddressOpt
impl AsRef<AddressOpt> for AddressOpt
source§impl Clone for AddressOpt
impl Clone for AddressOpt
source§fn clone(&self) -> AddressOpt
fn clone(&self) -> AddressOpt
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for AddressOpt
impl Debug for AddressOpt
source§impl<'de> Deserialize<'de> for AddressOpt
impl<'de> Deserialize<'de> for AddressOpt
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 Display for AddressOpt
impl Display for AddressOpt
source§impl EnumDebug for AddressOpt
impl EnumDebug for AddressOpt
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<&AddressOpt> for AddressOpt
impl From<&AddressOpt> for AddressOpt
source§fn from(value: &AddressOpt) -> Self
fn from(value: &AddressOpt) -> Self
Converts to this type from the input type.
source§impl From<&mut AddressOpt> for AddressOpt
impl From<&mut AddressOpt> for AddressOpt
source§fn from(value: &mut AddressOpt) -> Self
fn from(value: &mut AddressOpt) -> Self
Converts to this type from the input type.
source§impl From<Address> for AddressOpt
impl From<Address> for AddressOpt
source§impl FromStr for AddressOpt
impl FromStr for AddressOpt
source§impl Serialize for AddressOpt
impl Serialize 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 AddressOpt
impl RefUnwindSafe for AddressOpt
impl Send for AddressOpt
impl Sync for AddressOpt
impl Unpin for AddressOpt
impl UnwindSafe for AddressOpt
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