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 untillenbytes. - Padding bytes do not need to be initialized.
 - The address does not need to be aligned.
 - If 
lenis large enough for the address to hold the family field, the family must correctly represent the address type. For example ifaddrpoints to asockaddr_in, thenaddr.sin_familymust 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§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