#[repr(C)]
pub union SockaddrStorage {
/* private fields */
}
Expand description
A container for any sockaddr type
Just like C’s sockaddr_storage
, this type is large enough to hold any type
of sockaddr. It can be used as an argument with functions like
bind
and getsockname
. Though it is
a union, it can be safely accessed through the as_*
methods.
§Example
let localhost = SockaddrIn::from_str("127.0.0.1:8081").unwrap();
let fd = socket(AddressFamily::Inet, SockType::Stream, SockFlag::empty(),
None).unwrap();
bind(fd, &localhost).expect("bind");
let ss: SockaddrStorage = getsockname(fd).expect("getsockname");
assert_eq!(&localhost, ss.as_sockaddr_in().unwrap());
Implementations§
Source§impl SockaddrStorage
impl SockaddrStorage
Sourcepub fn as_unix_addr(&self) -> Option<&UnixAddr>
pub fn as_unix_addr(&self) -> Option<&UnixAddr>
Downcast to an immutable [UnixAddr]
reference.
Sourcepub fn as_unix_addr_mut(&mut self) -> Option<&mut UnixAddr>
pub fn as_unix_addr_mut(&mut self) -> Option<&mut UnixAddr>
Downcast to a mutable [UnixAddr]
reference.
Sourcepub fn as_alg_addr(&self) -> Option<&AlgAddr>
pub fn as_alg_addr(&self) -> Option<&AlgAddr>
Safely and falliably downcast to an immutable reference
Sourcepub fn as_alg_addr_mut(&mut self) -> Option<&mut AlgAddr>
pub fn as_alg_addr_mut(&mut self) -> Option<&mut AlgAddr>
Safely and falliably downcast to a mutable reference
Sourcepub fn as_link_addr(&self) -> Option<&LinkAddr>
pub fn as_link_addr(&self) -> Option<&LinkAddr>
Safely and falliably downcast to an immutable reference
Sourcepub fn as_link_addr_mut(&mut self) -> Option<&mut LinkAddr>
pub fn as_link_addr_mut(&mut self) -> Option<&mut LinkAddr>
Safely and falliably downcast to a mutable reference
Sourcepub fn as_sockaddr_in(&self) -> Option<&SockaddrIn>
pub fn as_sockaddr_in(&self) -> Option<&SockaddrIn>
Safely and falliably downcast to an immutable reference
Sourcepub fn as_sockaddr_in_mut(&mut self) -> Option<&mut SockaddrIn>
pub fn as_sockaddr_in_mut(&mut self) -> Option<&mut SockaddrIn>
Safely and falliably downcast to a mutable reference
Sourcepub fn as_sockaddr_in6(&self) -> Option<&SockaddrIn6>
pub fn as_sockaddr_in6(&self) -> Option<&SockaddrIn6>
Safely and falliably downcast to an immutable reference
Sourcepub fn as_sockaddr_in6_mut(&mut self) -> Option<&mut SockaddrIn6>
pub fn as_sockaddr_in6_mut(&mut self) -> Option<&mut SockaddrIn6>
Safely and falliably downcast to a mutable reference
Sourcepub fn as_netlink_addr(&self) -> Option<&NetlinkAddr>
pub fn as_netlink_addr(&self) -> Option<&NetlinkAddr>
Safely and falliably downcast to an immutable reference
Sourcepub fn as_netlink_addr_mut(&mut self) -> Option<&mut NetlinkAddr>
pub fn as_netlink_addr_mut(&mut self) -> Option<&mut NetlinkAddr>
Safely and falliably downcast to a mutable reference
Sourcepub fn as_vsock_addr(&self) -> Option<&VsockAddr>
pub fn as_vsock_addr(&self) -> Option<&VsockAddr>
Safely and falliably downcast to an immutable reference
Sourcepub fn as_vsock_addr_mut(&mut self) -> Option<&mut VsockAddr>
pub fn as_vsock_addr_mut(&mut self) -> Option<&mut VsockAddr>
Safely and falliably downcast to a mutable reference
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 more