pub enum EndpointAddr {
Direct {
addr: SocketAddr,
},
Agent {
agent: SocketAddr,
outer: SocketAddr,
},
}Variants§
Implementations§
Source§impl EndpointAddr
impl EndpointAddr
pub fn direct(addr: SocketAddr) -> Self
pub fn with_agent(agent: SocketAddr, outer: SocketAddr) -> Self
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 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
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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§impl<'de> Deserialize<'de> for EndpointAddr
impl<'de> Deserialize<'de> for EndpointAddr
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 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((agent, outer): (SocketAddr, SocketAddr)) -> Self
fn from((agent, outer): (SocketAddr, SocketAddr)) -> Self
Converts to this type from the input type.
Source§impl From<SocketAddr> for EndpointAddr
impl From<SocketAddr> for EndpointAddr
Source§fn from(addr: SocketAddr) -> Self
fn from(addr: SocketAddr) -> Self
Converts to this type from the input type.
Source§impl FromStr for EndpointAddr
impl FromStr for EndpointAddr
Source§impl Hash for EndpointAddr
impl Hash for EndpointAddr
Source§impl Ord for EndpointAddr
impl Ord for EndpointAddr
Source§fn cmp(&self, other: &EndpointAddr) -> Ordering
fn cmp(&self, other: &EndpointAddr) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for EndpointAddr
impl PartialEq for EndpointAddr
Source§fn eq(&self, other: &EndpointAddr) -> bool
fn eq(&self, other: &EndpointAddr) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for EndpointAddr
impl PartialOrd for EndpointAddr
Source§impl Serialize for EndpointAddr
impl Serialize for EndpointAddr
impl StructuralPartialEq for EndpointAddr
Auto Trait Implementations§
impl Freeze for EndpointAddr
impl RefUnwindSafe for EndpointAddr
impl Send for EndpointAddr
impl Sync for EndpointAddr
impl Unpin for EndpointAddr
impl UnsafeUnpin for EndpointAddr
impl UnwindSafe for EndpointAddr
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