Struct socket2::SockAddr
[−]
[src]
pub struct SockAddr { /* fields omitted */ }
The address of a socket.
SockAddr
s may be constructed directly to and from the standard library
SocketAddr
, SocketAddrV4
, and SocketAddrV6
types.
Methods
impl SockAddr
[src]
unsafe fn from_raw_parts(addr: *const sockaddr, len: socklen_t) -> SockAddr
[src]
Constructs a SockAddr
from its raw components.
fn unix<P>(path: P) -> Result<SockAddr> where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
Constructs a SockAddr
with the family AF_UNIX
and the provided path.
This function is only available on Unix when the unix
feature is
enabled.
Failure
Returns an error if the path is longer than SUN_LEN
.
fn as_inet(&self) -> Option<SocketAddrV4>
[src]
Returns this address as a SocketAddrV4
if it is in the AF_INET
family.
fn as_inet6(&self) -> Option<SocketAddrV6>
[src]
Returns this address as a SocketAddrV4
if it is in the AF_INET6
family.
fn family(&self) -> sa_family_t
[src]
Returns this address's family.
fn len(&self) -> socklen_t
[src]
Returns the size of this address in bytes.
fn as_ptr(&self) -> *const sockaddr
[src]
Returns a raw pointer to the address.
Trait Implementations
impl Debug for SockAddr
[src]
impl From<SocketAddrV4> for SockAddr
[src]
fn from(addr: SocketAddrV4) -> SockAddr
[src]
Performs the conversion.
impl From<SocketAddrV6> for SockAddr
[src]
fn from(addr: SocketAddrV6) -> SockAddr
[src]
Performs the conversion.
impl From<SocketAddr> for SockAddr
[src]
fn from(addr: SocketAddr) -> SockAddr
[src]
Performs the conversion.