[][src]Trait posix_socket::AsSocketAddress

pub unsafe trait AsSocketAddress: Sized {
    fn as_sockaddr(&self) -> *const sockaddr;
fn len(&self) -> socklen_t;
fn as_sockaddr_mut(address: &mut MaybeUninit<Self>) -> *mut sockaddr;
fn max_len() -> socklen_t;
fn finalize(address: MaybeUninit<Self>, len: socklen_t) -> Result<Self>; fn family(&self) -> sa_family_t { ... } }

A type that is binary compatible with a socket address.

Safety

It must be valid to construct a new address as [std::mem::MaybeUninit::new_zeroed()] and then write the socket address to the pointer returned by [as_sockaddr_mut()].

Required methods

fn as_sockaddr(&self) -> *const sockaddr

Get a pointer to the socket address.

In reality, this should point to a struct that is compatible with libc::sockaddr, but is not libc::sockaddr itself.

fn len(&self) -> socklen_t

Get the lengths of the socket address.

This is the length of the entire socket address, including the sa_family field.

fn as_sockaddr_mut(address: &mut MaybeUninit<Self>) -> *mut sockaddr

Get a mutable pointer to the socket address.

In reality, this should point to a struct that is compatible with libc::sockaddr, but is not libc::sockaddr itself.

fn max_len() -> socklen_t

Get the maximum size of for the socket address.

This is used to tell the kernel how much it is allowed to write to the memory pointed at by as_sockaddr_mut().

fn finalize(address: MaybeUninit<Self>, len: socklen_t) -> Result<Self>

Finalize a socket address that has been written into by the kernel.

This should check the address family and the length to ensure the address is valid. The length is the length of the entire socket address, including the sa_family field.

Loading content...

Provided methods

fn family(&self) -> sa_family_t

Get the address family of the socket address.

Loading content...

Implementors

impl AsSocketAddress for Inet4SocketAddress[src]

impl AsSocketAddress for Inet6SocketAddress[src]

impl AsSocketAddress for SocketAddress[src]

impl AsSocketAddress for UnixSocketAddress[src]

Loading content...