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
impl SockaddrStorage
sourcepub unsafe fn from_ptr(
addr: *const MaybeUninit<u8>,
len: socklen_t,
) -> Option<SockaddrStorage>
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 untillen
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 ifaddr
points to asockaddr_in
, thenaddr.sin_family
must beAF_INET
.
sourcepub unsafe fn from_bytes(address: &[MaybeUninit<u8>]) -> Option<Self>
pub unsafe fn from_bytes(address: &[MaybeUninit<u8>]) -> Option<Self>
§Safety
See Self::from_ptr
.
sourcepub fn family(&self) -> Option<AddressFamily>
pub fn family(&self) -> Option<AddressFamily>
Get the socket protocol family. Will return None
if the socket address length is too
short.
sourcepub fn as_inet(&self) -> Option<&SockaddrIn>
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.
sourcepub fn from_inet(addr: &SockaddrIn) -> Self
pub fn from_inet(addr: &SockaddrIn) -> Self
Get a new SockaddrStorage
with a copy of the ipv4 socket address.
sourcepub fn as_inet6(&self) -> Option<&SockaddrIn6>
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.
sourcepub fn from_inet6(addr: &SockaddrIn6) -> Self
pub fn from_inet6(addr: &SockaddrIn6) -> Self
Get a new SockaddrStorage
with a copy of the ipv6 socket address.
sourcepub fn as_unix(&self) -> Option<SockaddrUnix<&sockaddr_un>>
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.
sourcepub fn from_unix(addr: &SockaddrUnix<&sockaddr_un>) -> Self
pub fn from_unix(addr: &SockaddrUnix<&sockaddr_un>) -> Self
Get a new SockaddrStorage
with a copy of the unix socket address.
sourcepub fn as_netlink(&self) -> Option<&NetlinkAddr>
pub fn as_netlink(&self) -> Option<&NetlinkAddr>
If the socket address represents a valid netlink socket address (correct family and length), returns the netlink socket address.
sourcepub fn from_netlink(addr: &NetlinkAddr) -> Self
pub fn from_netlink(addr: &NetlinkAddr) -> Self
Get a new SockaddrStorage
with a copy of the netlink socket address.
sourcepub fn as_ptr(&self) -> (*const MaybeUninit<u8>, socklen_t)
pub fn as_ptr(&self) -> (*const MaybeUninit<u8>, socklen_t)
A pointer to the socket address. Some bytes may be uninitialized.
sourcepub fn as_slice(&self) -> &[MaybeUninit<u8>]
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
impl Clone for SockaddrStorage
source§fn clone(&self) -> SockaddrStorage
fn clone(&self) -> SockaddrStorage
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for SockaddrStorage
impl Debug for SockaddrStorage
source§impl Display for SockaddrStorage
impl Display for SockaddrStorage
source§impl From<NetlinkAddr> for SockaddrStorage
impl From<NetlinkAddr> for SockaddrStorage
source§fn from(addr: NetlinkAddr) -> Self
fn from(addr: NetlinkAddr) -> Self
source§impl From<SockaddrIn> for SockaddrStorage
impl From<SockaddrIn> for SockaddrStorage
source§fn from(addr: SockaddrIn) -> Self
fn from(addr: SockaddrIn) -> Self
source§impl From<SockaddrIn6> for SockaddrStorage
impl From<SockaddrIn6> for SockaddrStorage
source§fn from(addr: SockaddrIn6) -> Self
fn from(addr: SockaddrIn6) -> Self
source§impl<T> From<SockaddrUnix<T>> for SockaddrStoragewhere
T: Borrow<sockaddr_un>,
impl<T> From<SockaddrUnix<T>> for SockaddrStoragewhere
T: Borrow<sockaddr_un>,
source§fn from(addr: SockaddrUnix<T>) -> Self
fn from(addr: SockaddrUnix<T>) -> Self
source§impl From<SocketAddrV4> for SockaddrStorage
impl From<SocketAddrV4> for SockaddrStorage
source§fn from(addr: SocketAddrV4) -> Self
fn from(addr: SocketAddrV4) -> Self
source§impl From<SocketAddrV6> for SockaddrStorage
impl From<SocketAddrV6> for SockaddrStorage
source§fn from(addr: SocketAddrV6) -> Self
fn from(addr: SocketAddrV6) -> Self
impl Copy for SockaddrStorage
Auto Trait Implementations§
impl Freeze for SockaddrStorage
impl RefUnwindSafe for SockaddrStorage
impl Send for SockaddrStorage
impl Sync for SockaddrStorage
impl Unpin for SockaddrStorage
impl UnwindSafe for SockaddrStorage
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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