Enum inet2_addr::PartialSocketAddr
source · #[non_exhaustive]
pub enum PartialSocketAddr {
IPv4(Ipv4Addr, Option<u16>),
IPv6(Ipv6Addr, Option<u16>),
}
Expand description
A universal address covering IPv4, IPv6 and Tor in a single byte sequence of 32 bytes, which may contain optional port number part.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
IPv4(Ipv4Addr, Option<u16>)
IP address of V4 standard with optional port number
IPv6(Ipv6Addr, Option<u16>)
IP address of V6 standard with optional port number
Implementations§
source§impl PartialSocketAddr
impl PartialSocketAddr
sourcepub fn socket(ip: IpAddr, port: Option<u16>) -> Self
pub fn socket(ip: IpAddr, port: Option<u16>) -> Self
Constructs new socket address from an internet address and a port information
sourcepub fn is_tor(self) -> bool
pub fn is_tor(self) -> bool
Determines whether provided address is a Tor address. Always returns
false
(the library is built without tor
feature; use it to
enable Tor addresses).
sourcepub fn onion_address(self) -> Option<()>
pub fn onion_address(self) -> Option<()>
Always returns Option::None
(the library is built without tor
feature; use it to enable Tor addresses).
sourcepub fn port(self) -> Option<u16>
pub fn port(self) -> Option<u16>
Returns port for the socket, if address allows different ports.
sourcepub fn inet_socket(self, default_port: u16) -> InetSocketAddr
pub fn inet_socket(self, default_port: u16) -> InetSocketAddr
Constructs InetSocketAddr
using default port information.
Trait Implementations§
source§impl Clone for PartialSocketAddr
impl Clone for PartialSocketAddr
source§fn clone(&self) -> PartialSocketAddr
fn clone(&self) -> PartialSocketAddr
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 PartialSocketAddr
impl Debug for PartialSocketAddr
source§impl Default for PartialSocketAddr
impl Default for PartialSocketAddr
source§impl Display for PartialSocketAddr
impl Display for PartialSocketAddr
source§impl From<InetAddr> for PartialSocketAddr
impl From<InetAddr> for PartialSocketAddr
source§impl From<InetSocketAddr> for PartialSocketAddr
impl From<InetSocketAddr> for PartialSocketAddr
source§fn from(addr: InetSocketAddr) -> Self
fn from(addr: InetSocketAddr) -> Self
Converts to this type from the input type.
source§impl From<IpAddr> for PartialSocketAddr
impl From<IpAddr> for PartialSocketAddr
source§impl From<Ipv4Addr> for PartialSocketAddr
impl From<Ipv4Addr> for PartialSocketAddr
source§impl From<Ipv6Addr> for PartialSocketAddr
impl From<Ipv6Addr> for PartialSocketAddr
source§impl From<SocketAddr> for PartialSocketAddr
impl From<SocketAddr> for PartialSocketAddr
source§fn from(value: SocketAddr) -> Self
fn from(value: SocketAddr) -> Self
Converts to this type from the input type.
source§impl From<SocketAddrV4> for PartialSocketAddr
impl From<SocketAddrV4> for PartialSocketAddr
source§fn from(value: SocketAddrV4) -> Self
fn from(value: SocketAddrV4) -> Self
Converts to this type from the input type.
source§impl From<SocketAddrV6> for PartialSocketAddr
impl From<SocketAddrV6> for PartialSocketAddr
source§fn from(value: SocketAddrV6) -> Self
fn from(value: SocketAddrV6) -> Self
Converts to this type from the input type.
source§impl FromStr for PartialSocketAddr
impl FromStr for PartialSocketAddr
source§impl Hash for PartialSocketAddr
impl Hash for PartialSocketAddr
source§impl Ord for PartialSocketAddr
impl Ord for PartialSocketAddr
source§impl PartialEq<PartialSocketAddr> for PartialSocketAddr
impl PartialEq<PartialSocketAddr> for PartialSocketAddr
source§fn eq(&self, other: &PartialSocketAddr) -> bool
fn eq(&self, other: &PartialSocketAddr) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<PartialSocketAddr> for PartialSocketAddr
impl PartialOrd<PartialSocketAddr> for PartialSocketAddr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more