pub struct OsSocketAddr { /* private fields */ }
Expand description

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

This type has a buffer big enough to hold 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 SocketAddr.

See crate level documentation.

Implementations

Create a new empty socket address

Create a new socket address from a raw slice

Panics

Panics if len is bigger that the size of sockaddr_in6

Create a new socket address from a SocketAddr object

Attempt to convert the internal buffer into a SocketAddr object

The internal buffer is assumed to be a 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.

Return the length of the address

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

Return the size of the internal buffer

Get a pointer to the internal buffer

Get a mutable pointer to the internal buffer

Trait Implementations

Get the internal buffer as a mutable slice

Get the internal buffer as a byte slice

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Attempt to convert the internal buffer into a SocketAddr object

The internal buffer is assumed to be a 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.

Attempt to convert the internal buffer into a SocketAddr object

The internal buffer is assumed to be a 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 an error.

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.