Struct SocketAddress

Source
#[repr(C)]
pub struct SocketAddress { /* private fields */ }
Expand description

Generic socket address, large enough to hold any valid address.

Implementations§

Source§

impl SocketAddress

Source

pub fn from_raw(inner: sockaddr_storage, len: socklen_t) -> Self

Create a SocketAddress from a libc::sockaddr_storage and a length.

Source

pub fn from_other<Address: AsSocketAddress>(other: &Address) -> Self

Create a generic SocketAddress by copying data from another address.

Source

pub fn into_raw(self) -> (sockaddr_storage, socklen_t)

Convert the SocketAddress into raw libc parts.

Source

pub fn family(&self) -> c_int

Get the address family.

Source

pub fn as_inet4(&self) -> Option<Inet4SocketAddress>

Get the address as an IPv4 socket address.

Returns None if the address is not an IPv4 socket address.

Source

pub fn as_inet6(&self) -> Option<Inet6SocketAddress>

Get the address as an IPv6 socket address.

Returns None if the address is not an IPv6 socket address.

Source

pub fn as_unix(&self) -> Option<UnixSocketAddress>

Get the address as an unix socket address.

Returns None if the address is not a unix socket address.

Trait Implementations§

Source§

impl AsSocketAddress for SocketAddress

Source§

fn as_sockaddr(&self) -> *const sockaddr

Get a pointer to the socket address. Read more
Source§

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

Get a mutable pointer to the socket address. Read more
Source§

fn len(&self) -> socklen_t

Get the lengths of the socket address. Read more
Source§

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

Finalize a socket address that has been written into by the kernel. Read more
Source§

fn max_len() -> socklen_t

Get the maximum size of for the socket address. Read more
Source§

fn family(&self) -> sa_family_t

Get the address family of the socket address.
Source§

impl Clone for SocketAddress

Source§

fn clone(&self) -> SocketAddress

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl From<&Inet4SocketAddress> for SocketAddress

Source§

fn from(other: &Inet4SocketAddress) -> Self

Converts to this type from the input type.
Source§

impl From<&Inet6SocketAddress> for SocketAddress

Source§

fn from(other: &Inet6SocketAddress) -> Self

Converts to this type from the input type.
Source§

impl From<&UnixSocketAddress> for SocketAddress

Source§

fn from(other: &UnixSocketAddress) -> Self

Converts to this type from the input type.
Source§

impl From<Inet4SocketAddress> for SocketAddress

Source§

fn from(other: Inet4SocketAddress) -> Self

Converts to this type from the input type.
Source§

impl From<Inet6SocketAddress> for SocketAddress

Source§

fn from(other: Inet6SocketAddress) -> Self

Converts to this type from the input type.
Source§

impl From<UnixSocketAddress> for SocketAddress

Source§

fn from(other: UnixSocketAddress) -> Self

Converts to this type from the input type.
Source§

impl GenericSocketAddress for SocketAddress

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.