#[repr(C)]pub struct SocketAddress { /* private fields */ }
Expand description
Generic socket address, large enough to hold any valid address.
Implementations§
Source§impl SocketAddress
impl SocketAddress
Sourcepub fn from_raw(inner: sockaddr_storage, len: socklen_t) -> Self
pub fn from_raw(inner: sockaddr_storage, len: socklen_t) -> Self
Create a SocketAddress
from a libc::sockaddr_storage
and a length.
Sourcepub fn from_other<Address: AsSocketAddress>(other: &Address) -> Self
pub fn from_other<Address: AsSocketAddress>(other: &Address) -> Self
Create a generic SocketAddress
by copying data from another address.
Sourcepub fn into_raw(self) -> (sockaddr_storage, socklen_t)
pub fn into_raw(self) -> (sockaddr_storage, socklen_t)
Convert the SocketAddress
into raw libc
parts.
Sourcepub fn as_inet4(&self) -> Option<Inet4SocketAddress>
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.
Sourcepub fn as_inet6(&self) -> Option<Inet6SocketAddress>
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.
Sourcepub fn as_unix(&self) -> Option<UnixSocketAddress>
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
impl AsSocketAddress for SocketAddress
Source§fn as_sockaddr_mut(address: &mut MaybeUninit<Self>) -> *mut sockaddr
fn as_sockaddr_mut(address: &mut MaybeUninit<Self>) -> *mut sockaddr
Get a mutable pointer to the socket address. Read more
Source§fn finalize(address: MaybeUninit<Self>, len: socklen_t) -> Result<Self>
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 family(&self) -> sa_family_t
fn family(&self) -> sa_family_t
Get the address family of the socket address.
Source§impl Clone for SocketAddress
impl Clone for SocketAddress
Source§fn clone(&self) -> SocketAddress
fn clone(&self) -> SocketAddress
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 From<&Inet4SocketAddress> for SocketAddress
impl From<&Inet4SocketAddress> for SocketAddress
Source§fn from(other: &Inet4SocketAddress) -> Self
fn from(other: &Inet4SocketAddress) -> Self
Converts to this type from the input type.
Source§impl From<&Inet6SocketAddress> for SocketAddress
impl From<&Inet6SocketAddress> for SocketAddress
Source§fn from(other: &Inet6SocketAddress) -> Self
fn from(other: &Inet6SocketAddress) -> Self
Converts to this type from the input type.
Source§impl From<&UnixSocketAddress> for SocketAddress
impl From<&UnixSocketAddress> for SocketAddress
Source§fn from(other: &UnixSocketAddress) -> Self
fn from(other: &UnixSocketAddress) -> Self
Converts to this type from the input type.
Source§impl From<Inet4SocketAddress> for SocketAddress
impl From<Inet4SocketAddress> for SocketAddress
Source§fn from(other: Inet4SocketAddress) -> Self
fn from(other: Inet4SocketAddress) -> Self
Converts to this type from the input type.
Source§impl From<Inet6SocketAddress> for SocketAddress
impl From<Inet6SocketAddress> for SocketAddress
Source§fn from(other: Inet6SocketAddress) -> Self
fn from(other: Inet6SocketAddress) -> Self
Converts to this type from the input type.
Source§impl From<UnixSocketAddress> for SocketAddress
impl From<UnixSocketAddress> for SocketAddress
Source§fn from(other: UnixSocketAddress) -> Self
fn from(other: UnixSocketAddress) -> Self
Converts to this type from the input type.
impl GenericSocketAddress for SocketAddress
Auto Trait Implementations§
impl Freeze for SocketAddress
impl RefUnwindSafe for SocketAddress
impl Send for SocketAddress
impl Sync for SocketAddress
impl Unpin for SocketAddress
impl UnwindSafe for SocketAddress
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