pub enum NetworkAddress {
Dns {
hostname: String,
port: Option<u16>,
},
Ipv4 {
address: Ipv4Addr,
port: Option<u16>,
},
Ipv6 {
address: Ipv6Addr,
port: Option<u16>,
},
}Expand description
Network address information for connecting to a service
Supports multiple address types including DNS names, IPv4, and IPv6 addresses with optional port specifications for maximum flexibility.
Variants§
Dns
DNS hostname with optional port
Examples: “relay.example.com”, “relay.example.com:8443” If no port is specified, the default port should be used.
Ipv4
IPv4 address with optional port
Examples: “192.168.1.100”, “192.168.1.100:8443” If no port is specified, the default port should be used.
Ipv6
IPv6 address with optional port
Examples: “::1”, “[::1]:8443” If no port is specified, the default port should be used.
Implementations§
Source§impl NetworkAddress
impl NetworkAddress
Sourcepub fn dns_with_port(hostname: impl Into<String>, port: u16) -> Self
pub fn dns_with_port(hostname: impl Into<String>, port: u16) -> Self
Create a DNS network address with port
Sourcepub fn ipv4_with_port(address: Ipv4Addr, port: u16) -> Self
pub fn ipv4_with_port(address: Ipv4Addr, port: u16) -> Self
Create an IPv4 network address with port
Sourcepub fn ipv6_with_port(address: Ipv6Addr, port: u16) -> Self
pub fn ipv6_with_port(address: Ipv6Addr, port: u16) -> Self
Create an IPv6 network address with port
Sourcepub fn port_or_default(&self, default_port: u16) -> u16
pub fn port_or_default(&self, default_port: u16) -> u16
Get the port if specified, otherwise return the default port
Sourcepub async fn resolve_to_socket_addr(
&self,
default_port: u16,
) -> Result<SocketAddr, String>
pub async fn resolve_to_socket_addr( &self, default_port: u16, ) -> Result<SocketAddr, String>
Resolve this network address to a socket address
For IP addresses, returns immediately. For DNS addresses, performs resolution.
Trait Implementations§
Source§impl Clone for NetworkAddress
impl Clone for NetworkAddress
Source§fn clone(&self) -> NetworkAddress
fn clone(&self) -> NetworkAddress
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NetworkAddress
impl Debug for NetworkAddress
Source§impl<'de> Deserialize<'de> for NetworkAddress
impl<'de> Deserialize<'de> for NetworkAddress
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>,
Source§impl Display for NetworkAddress
impl Display for NetworkAddress
Source§impl From<&str> for NetworkAddress
impl From<&str> for NetworkAddress
Source§impl From<IpAddr> for NetworkAddress
impl From<IpAddr> for NetworkAddress
Source§impl From<SocketAddr> for NetworkAddress
impl From<SocketAddr> for NetworkAddress
Source§fn from(addr: SocketAddr) -> Self
fn from(addr: SocketAddr) -> Self
Source§impl From<String> for NetworkAddress
impl From<String> for NetworkAddress
Source§impl Ord for NetworkAddress
impl Ord for NetworkAddress
Source§fn cmp(&self, other: &NetworkAddress) -> Ordering
fn cmp(&self, other: &NetworkAddress) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for NetworkAddress
impl PartialEq for NetworkAddress
Source§impl PartialOrd for NetworkAddress
impl PartialOrd for NetworkAddress
Source§impl Serialize for NetworkAddress
impl Serialize for NetworkAddress
impl Eq for NetworkAddress
impl StructuralPartialEq for NetworkAddress
Auto Trait Implementations§
impl Freeze for NetworkAddress
impl RefUnwindSafe for NetworkAddress
impl Send for NetworkAddress
impl Sync for NetworkAddress
impl Unpin for NetworkAddress
impl UnwindSafe for NetworkAddress
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> Classify for T
impl<T> Classify for T
type Classified = T
fn classify(self) -> T
§impl<T> Classify for T
impl<T> Classify for T
type Classified = T
fn classify(self) -> T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.