pub struct SocketAddrAny { /* private fields */ }
Available on crate feature
net
only.Expand description
A type that can hold any kind of socket address, as a safe abstraction for
sockaddr_storage
.
Socket addresses can be converted to SocketAddrAny
via the From
and
Into
traits. SocketAddrAny
can be converted back to a specific socket
address type with TryFrom
and TryInto
. These implementations return
Errno::AFNOSUPPORT
if the address family does not match the requested
type.
Implementations§
Source§impl SocketAddrAny
impl SocketAddrAny
Sourcepub const unsafe fn new(
storage: MaybeUninit<SocketAddrStorage>,
len: SocketAddrLen,
) -> Self
pub const unsafe fn new( storage: MaybeUninit<SocketAddrStorage>, len: SocketAddrLen, ) -> Self
Sourcepub unsafe fn read(ptr: *const SocketAddrStorage, len: SocketAddrLen) -> Self
pub unsafe fn read(ptr: *const SocketAddrStorage, len: SocketAddrLen) -> Self
Sourcepub fn address_family(&self) -> AddressFamily
pub fn address_family(&self) -> AddressFamily
Gets the address family of this socket address.
Sourcepub fn as_ptr(&self) -> *const SocketAddrStorage
pub fn as_ptr(&self) -> *const SocketAddrStorage
Returns a raw pointer to the sockaddr.
Sourcepub fn as_mut_ptr(&mut self) -> *mut SocketAddrStorage
pub fn as_mut_ptr(&mut self) -> *mut SocketAddrStorage
Returns a raw mutable pointer to the sockaddr.
Sourcepub fn addr_len(&self) -> SocketAddrLen
pub fn addr_len(&self) -> SocketAddrLen
Returns the length of the encoded sockaddr.
Trait Implementations§
Source§impl Clone for SocketAddrAny
impl Clone for SocketAddrAny
Source§fn clone(&self) -> SocketAddrAny
fn clone(&self) -> SocketAddrAny
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SocketAddrAny
impl Debug for SocketAddrAny
Source§impl From<SocketAddr> for SocketAddrAny
impl From<SocketAddr> for SocketAddrAny
Source§fn from(from: SocketAddr) -> Self
fn from(from: SocketAddr) -> Self
Converts to this type from the input type.
Source§impl From<SocketAddrNetlink> for SocketAddrAny
impl From<SocketAddrNetlink> for SocketAddrAny
Source§fn from(from: SocketAddrNetlink) -> Self
fn from(from: SocketAddrNetlink) -> Self
Converts to this type from the input type.
Source§impl From<SocketAddrUnix> for SocketAddrAny
impl From<SocketAddrUnix> for SocketAddrAny
Source§fn from(from: SocketAddrUnix) -> Self
fn from(from: SocketAddrUnix) -> Self
Converts to this type from the input type.
Source§impl From<SocketAddrV4> for SocketAddrAny
impl From<SocketAddrV4> for SocketAddrAny
Source§fn from(from: SocketAddrV4) -> Self
fn from(from: SocketAddrV4) -> Self
Converts to this type from the input type.
Source§impl From<SocketAddrV6> for SocketAddrAny
impl From<SocketAddrV6> for SocketAddrAny
Source§fn from(from: SocketAddrV6) -> Self
fn from(from: SocketAddrV6) -> Self
Converts to this type from the input type.
Source§impl From<SocketAddrXdp> for SocketAddrAny
impl From<SocketAddrXdp> for SocketAddrAny
Source§fn from(from: SocketAddrXdp) -> Self
fn from(from: SocketAddrXdp) -> Self
Converts to this type from the input type.
Source§impl Hash for SocketAddrAny
impl Hash for SocketAddrAny
Source§impl Ord for SocketAddrAny
impl Ord for SocketAddrAny
Source§impl PartialEq for SocketAddrAny
impl PartialEq for SocketAddrAny
Source§impl PartialOrd for SocketAddrAny
impl PartialOrd for SocketAddrAny
Source§impl SocketAddrArg for SocketAddrAny
impl SocketAddrArg for SocketAddrAny
Source§unsafe fn with_sockaddr<R>(
&self,
f: impl FnOnce(*const SocketAddrOpaque, SocketAddrLen) -> R,
) -> R
unsafe fn with_sockaddr<R>( &self, f: impl FnOnce(*const SocketAddrOpaque, SocketAddrLen) -> R, ) -> R
Call a closure with the pointer and length to the corresponding C type. Read more
Source§fn as_any(&self) -> SocketAddrAny
fn as_any(&self) -> SocketAddrAny
Convert to
SocketAddrAny
.Source§unsafe fn write_sockaddr(
&self,
storage: *mut SocketAddrStorage,
) -> SocketAddrLen
unsafe fn write_sockaddr( &self, storage: *mut SocketAddrStorage, ) -> SocketAddrLen
Encode an address into a
SocketAddrStorage
. Read moreSource§impl TryFrom<SocketAddrAny> for SocketAddr
impl TryFrom<SocketAddrAny> for SocketAddr
Source§impl TryFrom<SocketAddrAny> for SocketAddrNetlink
impl TryFrom<SocketAddrAny> for SocketAddrNetlink
Source§impl TryFrom<SocketAddrAny> for SocketAddrUnix
impl TryFrom<SocketAddrAny> for SocketAddrUnix
Source§impl TryFrom<SocketAddrAny> for SocketAddrV4
impl TryFrom<SocketAddrAny> for SocketAddrV4
Source§impl TryFrom<SocketAddrAny> for SocketAddrV6
impl TryFrom<SocketAddrAny> for SocketAddrV6
Source§impl TryFrom<SocketAddrAny> for SocketAddrXdp
impl TryFrom<SocketAddrAny> for SocketAddrXdp
impl Eq for SocketAddrAny
Auto Trait Implementations§
impl Freeze for SocketAddrAny
impl RefUnwindSafe for SocketAddrAny
impl Send for SocketAddrAny
impl Sync for SocketAddrAny
impl Unpin for SocketAddrAny
impl UnwindSafe for SocketAddrAny
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
Mutably borrows from an owned value. Read more