Struct os_socketaddr::OsSocketAddr [] [src]

pub struct OsSocketAddr { /* fields omitted */ }

A type for handling platform-native socket addresses (struct sockaddr)

This type holds a buffer enough big to have a libc::sockaddr_in or libc::sockaddr_in6 struct. Its content can be arbitrary written using .as_mut() or .as_mut_ptr().

It also provides the conversion functions from/into std::net::SocketAddr.

See module level documentation for more details.

Methods

impl OsSocketAddr
[src]

[src]

Create a new empty socket address

[src]

Create a new socket address from a raw slice

Panics

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

[src]

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

[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.

[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

[src]

Return the size of the internal buffer

[src]

Get a pointer to the internal buffer

[src]

Get a mutable pointer to the internal buffer

Trait Implementations

impl Copy for OsSocketAddr
[src]

impl Clone for OsSocketAddr
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

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

[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 AsMut<[u8]> for OsSocketAddr
[src]

[src]

Get the internal buffer as a mutable slice

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

[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.

impl From<SocketAddr> for OsSocketAddr
[src]

[src]

Performs the conversion.

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

[src]

Performs the conversion.

impl Debug for OsSocketAddr
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for OsSocketAddr

impl Sync for OsSocketAddr