pub enum EndpointAddr {
Direct {
addr: SocketAddr,
},
Mediate {
agent: SocketAddr,
outer: SocketAddr,
},
}Variants§
Implementations§
Source§impl EndpointAddr
impl EndpointAddr
pub fn direct(addr: SocketAddr) -> EndpointAddr
pub fn mediate(agent: SocketAddr, outer: SocketAddr) -> EndpointAddr
Sourcepub fn addr(&self) -> SocketAddr
pub fn addr(&self) -> SocketAddr
Returns the outer addr of this EndpointAddr
Note: Before successful hole punching with this Endpoint, packets should be sent to the addr returned by deref() to establish communication. Once hole punching is successful or about to begin, use the addr returned by this function.
pub fn kind(&self) -> Kind
Sourcepub fn is_globally_routable(&self) -> bool
pub fn is_globally_routable(&self) -> bool
Returns whether this endpoint can be reached through public routing.
A direct endpoint must contain a globally reachable unicast address. A mediated endpoint is considered publicly reachable through its validated agent.
pub fn encoding_size(&self) -> usize
Methods from Deref<Target = SocketAddr>§
1.7.0 · Sourcepub fn ip(&self) -> IpAddr
pub fn ip(&self) -> IpAddr
Returns the IP address associated with this socket address.
§Examples
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
assert_eq!(socket.ip(), IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)));1.0.0 · Sourcepub fn port(&self) -> u16
pub fn port(&self) -> u16
Returns the port number associated with this socket address.
§Examples
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
assert_eq!(socket.port(), 8080);1.16.0 · Sourcepub fn is_ipv4(&self) -> bool
pub fn is_ipv4(&self) -> bool
Returns true if the IP address in this SocketAddr is an
IPv4 address, and false otherwise.
§Examples
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
assert_eq!(socket.is_ipv4(), true);
assert_eq!(socket.is_ipv6(), false);1.16.0 · Sourcepub fn is_ipv6(&self) -> bool
pub fn is_ipv6(&self) -> bool
Returns true if the IP address in this SocketAddr is an
IPv6 address, and false otherwise.
§Examples
use std::net::{IpAddr, Ipv6Addr, SocketAddr};
let socket = SocketAddr::new(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 65535, 0, 1)), 8080);
assert_eq!(socket.is_ipv4(), false);
assert_eq!(socket.is_ipv6(), true);Trait Implementations§
Source§impl Clone for EndpointAddr
impl Clone for EndpointAddr
Source§fn clone(&self) -> EndpointAddr
fn clone(&self) -> EndpointAddr
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for EndpointAddr
Source§impl Debug for EndpointAddr
impl Debug for EndpointAddr
Source§impl Deref for EndpointAddr
impl Deref for EndpointAddr
Source§type Target = SocketAddr
type Target = SocketAddr
Source§impl<'de> Deserialize<'de> for EndpointAddr
impl<'de> Deserialize<'de> for EndpointAddr
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<EndpointAddr, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<EndpointAddr, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for EndpointAddr
impl Display for EndpointAddr
impl Eq for EndpointAddr
Source§impl From<(SocketAddr, SocketAddr)> for EndpointAddr
impl From<(SocketAddr, SocketAddr)> for EndpointAddr
Source§fn from(_: (SocketAddr, SocketAddr)) -> EndpointAddr
fn from(_: (SocketAddr, SocketAddr)) -> EndpointAddr
Source§impl From<SocketAddr> for EndpointAddr
impl From<SocketAddr> for EndpointAddr
Source§fn from(addr: SocketAddr) -> EndpointAddr
fn from(addr: SocketAddr) -> EndpointAddr
Source§impl FromStr for EndpointAddr
impl FromStr for EndpointAddr
Source§type Err = AddrParseError
type Err = AddrParseError
Source§fn from_str(s: &str) -> Result<EndpointAddr, <EndpointAddr as FromStr>::Err>
fn from_str(s: &str) -> Result<EndpointAddr, <EndpointAddr as FromStr>::Err>
s to return a value of this type. Read more