Struct socket2::SockAddr[][src]

pub struct SockAddr { /* fields omitted */ }

The address of a socket.

SockAddrs may be constructed directly to and from the standard library SocketAddr, SocketAddrV4, and SocketAddrV6 types.

Implementations

impl SockAddr[src]

pub unsafe fn from_raw_parts(addr: *const sockaddr, len: socklen_t) -> SockAddr[src]

Constructs a SockAddr from its raw components.

pub fn unix<P>(path: P) -> Result<SockAddr> where
    P: AsRef<Path>, 
[src]

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.

pub fn as_inet(&self) -> Option<SocketAddrV4>[src]

Returns this address as a SocketAddrV4 if it is in the AF_INET family.

pub fn as_inet6(&self) -> Option<SocketAddrV6>[src]

Returns this address as a SocketAddrV6 if it is in the AF_INET6 family.

pub fn as_std(&self) -> Option<SocketAddr>[src]

Returns this address as a SocketAddr if it is in the AF_INET or AF_INET6 family, otherwise returns None.

pub fn family(&self) -> sa_family_t[src]

Returns this address’s family.

pub fn len(&self) -> socklen_t[src]

Returns the size of this address in bytes.

pub fn as_ptr(&self) -> *const sockaddr[src]

Returns a raw pointer to the address.

Trait Implementations

impl Debug for SockAddr[src]

impl From<SocketAddr> for SockAddr[src]

impl From<SocketAddrV4> for SockAddr[src]

impl From<SocketAddrV6> for SockAddr[src]

Auto Trait Implementations

impl RefUnwindSafe for SockAddr

impl Send for SockAddr

impl Sync for SockAddr

impl Unpin for SockAddr

impl UnwindSafe for SockAddr

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.