pub enum EndpointAddr {
Direct {
addr: SocketAddr,
},
Agent {
agent: SocketAddr,
outer: SocketAddr,
},
}
Variants§
Implementations§
Source§impl EndpointAddr
impl EndpointAddr
pub fn direct(addr: SocketAddr) -> EndpointAddr
pub fn with_agent(agent: SocketAddr, outer: SocketAddr) -> EndpointAddr
Sourcepub fn addr(&self) -> SocketAddr
pub fn addr(&self) -> SocketAddr
Returns the outer address of this EndpointAddr
Note: Before successful hole punching with this Endpoint, packets should be sent to the address returned by deref() to establish communication. Once hole punching is successful or about to begin, use the address 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 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 EndpointAddr
impl Debug for EndpointAddr
Source§impl Deref for EndpointAddr
impl Deref for EndpointAddr
Source§type Target = SocketAddr
type Target = SocketAddr
The resulting type after dereferencing.
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for EndpointAddr
impl Display for EndpointAddr
Source§impl FromStr for EndpointAddr
impl FromStr for EndpointAddr
Source§type Err = AddrParseError
type Err = AddrParseError
The associated error which can be returned from parsing.
Source§fn from_str(s: &str) -> Result<EndpointAddr, <EndpointAddr as FromStr>::Err>
fn from_str(s: &str) -> Result<EndpointAddr, <EndpointAddr as FromStr>::Err>
Parses a string
s
to return a value of this type. Read moreSource§impl Hash for EndpointAddr
impl Hash for EndpointAddr
Source§impl PartialEq for EndpointAddr
impl PartialEq for EndpointAddr
Source§impl Serialize for EndpointAddr
impl Serialize for EndpointAddr
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Source§impl ToEndpointAddr for EndpointAddr
impl ToEndpointAddr for EndpointAddr
fn to_endpoint_addr(self) -> EndpointAddr
impl Copy for EndpointAddr
impl Eq 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 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