#[non_exhaustive]
pub enum SockAddr {
Inet(InetAddr),
Unix(UnixAddr),
SysControl(SysControlAddr),
Link(LinkAddr),
}
Expand description
Represents a socket address
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Implementations§
source§impl SockAddr
impl SockAddr
pub fn new_inet(addr: InetAddr) -> SockAddr
pub fn new_unix<P: ?Sized + NixPath>(path: &P) -> Result<SockAddr>
pub fn new_sys_control(sockfd: RawFd, name: &str, unit: u32) -> Result<SockAddr>
pub fn family(&self) -> AddressFamily
pub fn to_str(&self) -> String
👎Deprecated since 0.23.0: use .to_string() instead
sourcepub fn as_ffi_pair(&self) -> (&sockaddr, socklen_t)
pub fn as_ffi_pair(&self) -> (&sockaddr, socklen_t)
Conversion from nix’s SockAddr type to the underlying libc sockaddr type.
This is useful for interfacing with other libc functions that don’t yet have nix wrappers. Returns a reference to the underlying data type (as a sockaddr reference) along with the size of the actual data type. sockaddr is commonly used as a proxy for a superclass as C doesn’t support inheritance, so many functions that take a sockaddr * need to take the size of the underlying type as well and then internally cast it back.