//! A socket address for any kind of socket. //! //! This is similar to [`std::net::SocketAddr`], but also supports Unix-domain //! socket addresses on Unix. //! //! # Safety //! //! The `read` and `write` functions allow decoding and encoding from and to //! OS-specific socket address representations in memory. #![allow(unsafe_code)]
impl SocketAddrAny { /// Return the address family of this socket address. #[inline] pubconstfn address_family(&self) -> AddressFamily { matchself { Self::V4(_) => AddressFamily::INET, Self::V6(_) => AddressFamily::INET6, #[cfg(unix)] Self::Unix(_) => AddressFamily::UNIX, #[cfg(target_os = "linux")] Self::Xdp(_) => AddressFamily::XDP,
}
}
/// Writes a platform-specific encoding of this socket address to /// the memory pointed to by `storage`, and returns the number of /// bytes used. /// /// # Safety /// /// `storage` must point to valid memory for encoding the socket /// address. pubunsafefn write(&self, storage: *mut SocketAddrStorage) -> usize {
backend::net::write_sockaddr::write_sockaddr(self, storage)
}
/// Reads a platform-specific encoding of a socket address from /// the memory pointed to by `storage`, which uses `len` bytes. /// /// # Safety /// /// `storage` must point to valid memory for decoding a socket /// address. pubunsafefn read(storage: *const SocketAddrStorage, len: usize) -> io::Result<Self> {
backend::net::read_sockaddr::read_sockaddr(storage, len)
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.