Struct os_socketaddr::OsSocketAddr[][src]

pub struct OsSocketAddr { /* fields omitted */ }

Implementations

impl OsSocketAddr[src]

pub fn new() -> Self[src]

Create a new empty socket address

pub unsafe fn from_raw_parts(ptr: *const u8, len: usize) -> Self[src]

Create a new socket address from a raw slice

Panics

Panics if len is bigger that the size of libc::sockaddr_in6

pub fn from(addr: SocketAddr) -> Self[src]

Create a new socket address from a std::net::SocketAddr object

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

Attempt to convert the internal buffer into a std::net::SocketAddr object

The internal buffer is assumed to be a libc::sockaddr.

If the value of .sa_family resolves to AF_INET or AF_INET6 then the buffer is converted into SocketAddr, otherwise the function returns None.

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

Return the length of the address

The result depends on the value of .sa_family in the internal buffer:

  • AF_INET -> the size of sockaddr_in
  • AF_INET6 -> the size of sockaddr_in6
  • other -> 0

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

Return the size of the internal buffer

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

Get a pointer to the internal buffer

pub fn as_mut_ptr(&mut self) -> *mut sockaddr[src]

Get a mutable pointer to the internal buffer

Trait Implementations

impl AsMut<[u8]> for OsSocketAddr[src]

fn as_mut(&mut self) -> &mut [u8][src]

Get the internal buffer as a mutable slice

impl AsRef<[u8]> for OsSocketAddr[src]

fn as_ref(&self) -> &[u8][src]

Get the internal buffer as a byte slice

Note: the actual length of slice depends on the value of .sa_family (see .len())

impl Clone for OsSocketAddr[src]

impl Copy for OsSocketAddr[src]

impl Debug for OsSocketAddr[src]

impl From<Option<SocketAddr>> for OsSocketAddr[src]

impl From<SocketAddr> for OsSocketAddr[src]

impl Into<Option<SocketAddr>> for OsSocketAddr[src]

fn into(self) -> Option<SocketAddr>[src]

Attempt to convert the internal buffer into a std::net::SocketAddr object

The internal buffer is assumed to be a libc::sockaddr.

If the value of .sa_family resolves to AF_INET or AF_INET6 then the buffer is converted into SocketAddr, otherwise the function returns None.

Auto Trait Implementations

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.