Struct shadow_rs::utility::sockaddr::SockaddrStorage

source ·
pub struct SockaddrStorage { /* private fields */ }
Expand description

A container for any type of socket address.

Implementations§

source§

impl SockaddrStorage

source

pub unsafe fn from_ptr( addr: *const MaybeUninit<u8>, len: socklen_t, ) -> Option<SockaddrStorage>

§Safety
  • The address must be fully initialized, including padding fields (for example sockaddr_in.sin_zero), up until len bytes.
  • Padding bytes do not need to be initialized.
  • The address does not need to be aligned.
  • If len is large enough for the address to hold the family field, the family must correctly represent the address type. For example if addr points to a sockaddr_in, then addr.sin_family must be AF_INET.
source

pub unsafe fn from_bytes(address: &[MaybeUninit<u8>]) -> Option<Self>

§Safety

See Self::from_ptr.

source

pub fn family(&self) -> Option<AddressFamily>

Get the socket protocol family. Will return None if the socket address length is too short.

source

pub fn as_inet(&self) -> Option<&SockaddrIn>

If the socket address represents a valid ipv4 socket address (correct family and length), returns the ipv4 socket address.

source

pub fn from_inet(addr: &SockaddrIn) -> Self

Get a new SockaddrStorage with a copy of the ipv4 socket address.

source

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

If the socket address represents a valid ipv6 socket address (correct family and length), returns the ipv6 socket address.

source

pub fn from_inet6(addr: &SockaddrIn6) -> Self

Get a new SockaddrStorage with a copy of the ipv6 socket address.

source

pub fn as_unix(&self) -> Option<SockaddrUnix<&sockaddr_un>>

If the socket address represents a valid unix socket address (correct family and length), returns the unix socket address.

source

pub fn from_unix(addr: &SockaddrUnix<&sockaddr_un>) -> Self

Get a new SockaddrStorage with a copy of the unix socket address.

If the socket address represents a valid netlink socket address (correct family and length), returns the netlink socket address.

Get a new SockaddrStorage with a copy of the netlink socket address.

source

pub fn as_ptr(&self) -> (*const MaybeUninit<u8>, socklen_t)

A pointer to the socket address. Some bytes may be uninitialized.

source

pub fn as_slice(&self) -> &[MaybeUninit<u8>]

The socket address as a slice of bytes. Some bytes may be uninitialized.

Trait Implementations§

source§

impl Clone for SockaddrStorage

source§

fn clone(&self) -> SockaddrStorage

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 Debug for SockaddrStorage

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for SockaddrStorage

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<NetlinkAddr> for SockaddrStorage

source§

fn from(addr: NetlinkAddr) -> Self

Converts to this type from the input type.
source§

impl From<SockaddrIn> for SockaddrStorage

source§

fn from(addr: SockaddrIn) -> Self

Converts to this type from the input type.
source§

impl From<SockaddrIn6> for SockaddrStorage

source§

fn from(addr: SockaddrIn6) -> Self

Converts to this type from the input type.
source§

impl<T> From<SockaddrUnix<T>> for SockaddrStorage
where T: Borrow<sockaddr_un>,

source§

fn from(addr: SockaddrUnix<T>) -> Self

Converts to this type from the input type.
source§

impl From<SocketAddrV4> for SockaddrStorage

source§

fn from(addr: SocketAddrV4) -> Self

Converts to this type from the input type.
source§

impl From<SocketAddrV6> for SockaddrStorage

source§

fn from(addr: SocketAddrV6) -> Self

Converts to this type from the input type.
source§

impl Copy for SockaddrStorage

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, dst: *mut T)

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

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

source§

fn __clone_box(&self, _: Private) -> *mut ()

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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> NoTypeInference for T

source§

type This = T

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. 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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> Host for T
where T: Debug + Send,

source§

impl<T> Host for T
where T: Debug + Send + 'static,

source§

impl<T> Host for T
where T: Host + Host,

source§

impl<T> StatusBarState for T
where T: Display + Send + Sync,