pub enum SocketEndpointAddr {
Direct {
addr: SocketAddr,
},
Agent {
agent: SocketAddr,
outer: SocketAddr,
},
}
Variants§
Implementations§
Source§impl SocketEndpointAddr
impl SocketEndpointAddr
pub fn direct(addr: SocketAddr) -> SocketEndpointAddr
pub fn with_agent(agent: SocketAddr, outer: SocketAddr) -> SocketEndpointAddr
Sourcepub fn addr(&self) -> SocketAddr
pub fn addr(&self) -> SocketAddr
Returns the outer addr of this SocketEndpointAddr
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.
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 SocketEndpointAddr
impl Clone for SocketEndpointAddr
Source§fn clone(&self) -> SocketEndpointAddr
fn clone(&self) -> SocketEndpointAddr
Returns a duplicate 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 SocketEndpointAddr
impl Debug for SocketEndpointAddr
Source§impl Deref for SocketEndpointAddr
impl Deref for SocketEndpointAddr
Source§type Target = SocketAddr
type Target = SocketAddr
The resulting type after dereferencing.
Source§impl<'de> Deserialize<'de> for SocketEndpointAddr
impl<'de> Deserialize<'de> for SocketEndpointAddr
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SocketEndpointAddr, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SocketEndpointAddr, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for SocketEndpointAddr
impl Display for SocketEndpointAddr
Source§impl From<(SocketAddr, SocketAddr)> for SocketEndpointAddr
impl From<(SocketAddr, SocketAddr)> for SocketEndpointAddr
Source§fn from(_: (SocketAddr, SocketAddr)) -> SocketEndpointAddr
fn from(_: (SocketAddr, SocketAddr)) -> SocketEndpointAddr
Converts to this type from the input type.
Source§impl From<SocketAddr> for SocketEndpointAddr
impl From<SocketAddr> for SocketEndpointAddr
Source§fn from(addr: SocketAddr) -> SocketEndpointAddr
fn from(addr: SocketAddr) -> SocketEndpointAddr
Converts to this type from the input type.
Source§impl From<SocketEndpointAddr> for EndpointAddr
impl From<SocketEndpointAddr> for EndpointAddr
Source§fn from(value: SocketEndpointAddr) -> EndpointAddr
fn from(value: SocketEndpointAddr) -> EndpointAddr
Converts to this type from the input type.
Source§impl FromStr for SocketEndpointAddr
impl FromStr for SocketEndpointAddr
Source§type Err = AddrParseError
type Err = AddrParseError
The associated error which can be returned from parsing.
Source§fn from_str(
s: &str,
) -> Result<SocketEndpointAddr, <SocketEndpointAddr as FromStr>::Err>
fn from_str( s: &str, ) -> Result<SocketEndpointAddr, <SocketEndpointAddr as FromStr>::Err>
Parses a string
s
to return a value of this type. Read moreSource§impl Hash for SocketEndpointAddr
impl Hash for SocketEndpointAddr
Source§impl Ord for SocketEndpointAddr
impl Ord for SocketEndpointAddr
Source§fn cmp(&self, other: &SocketEndpointAddr) -> Ordering
fn cmp(&self, other: &SocketEndpointAddr) -> Ordering
1.21.0 · 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 SocketEndpointAddr
impl PartialEq for SocketEndpointAddr
Source§impl PartialOrd for SocketEndpointAddr
impl PartialOrd for SocketEndpointAddr
Source§impl Serialize for SocketEndpointAddr
impl Serialize for SocketEndpointAddr
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 TryFrom<EndpointAddr> for SocketEndpointAddr
impl TryFrom<EndpointAddr> for SocketEndpointAddr
Source§type Error = TryIntoError<EndpointAddr>
type Error = TryIntoError<EndpointAddr>
The type returned in the event of a conversion error.
Source§fn try_from(
value: EndpointAddr,
) -> Result<SocketEndpointAddr, TryIntoError<EndpointAddr>>
fn try_from( value: EndpointAddr, ) -> Result<SocketEndpointAddr, TryIntoError<EndpointAddr>>
Performs the conversion.
impl Copy for SocketEndpointAddr
impl Eq for SocketEndpointAddr
impl StructuralPartialEq for SocketEndpointAddr
Auto Trait Implementations§
impl Freeze for SocketEndpointAddr
impl RefUnwindSafe for SocketEndpointAddr
impl Send for SocketEndpointAddr
impl Sync for SocketEndpointAddr
impl Unpin for SocketEndpointAddr
impl UnwindSafe for SocketEndpointAddr
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