pub struct SockAddrStorage(pub SOCKADDR_STORAGE);Expand description
The SockAddrStorage struct represents a socket address for IPv4 or IPv6 addresses.
It can be created from various Windows socket address types and can be converted
to a std::net::SocketAddr.
Tuple Fields§
§0: SOCKADDR_STORAGEImplementations§
Source§impl SockAddrStorage
impl SockAddrStorage
Sourcepub fn from_ip_string(ip_address: &str) -> Result<Self, AddrParseError>
pub fn from_ip_string(ip_address: &str) -> Result<Self, AddrParseError>
Sourcepub fn from_sockaddr(address: SOCKADDR) -> Self
pub fn from_sockaddr(address: SOCKADDR) -> Self
Constructs a new SockAddrStorage from a SOCKADDR struct.
§Safety
This function uses MaybeUninit to safely create an uninitialized
SOCKADDR_STORAGE instance, and then it copies the SOCKADDR contents
into the SOCKADDR_STORAGE without overlapping.
Before constructing the SockAddrStorage, it ensures that the contents
are valid using the assume_init() method.
Sourcepub fn from_sockaddr_in(address: SOCKADDR_IN) -> Self
pub fn from_sockaddr_in(address: SOCKADDR_IN) -> Self
Constructs a new SockAddrStorage from a SOCKADDR_IN struct.
§Safety
This function uses MaybeUninit to safely create an uninitialized
SOCKADDR_STORAGE instance, and then it copies the SOCKADDR_IN contents
into the SOCKADDR_STORAGE without overlapping.
Before constructing the SockAddrStorage, it ensures that the contents
are valid using the assume_init() method.
Sourcepub fn from_sockaddr_in6(address: SOCKADDR_IN6) -> Self
pub fn from_sockaddr_in6(address: SOCKADDR_IN6) -> Self
Constructs a new SockAddrStorage from a SOCKADDR_IN6 struct.
§Safety
This function uses MaybeUninit to safely create an uninitialized
SOCKADDR_STORAGE instance, and then it copies the SOCKADDR_IN6 contents
into the SOCKADDR_STORAGE without overlapping.
Before constructing the SockAddrStorage, it ensures that the contents
are valid using the assume_init() method.
Sourcepub fn from_ipv4_addr(address: Ipv4Addr) -> Self
pub fn from_ipv4_addr(address: Ipv4Addr) -> Self
Constructs a new SockAddrStorage from an Ipv4Addr object.
Sourcepub fn from_ipv6_addr(address: Ipv6Addr) -> Self
pub fn from_ipv6_addr(address: Ipv6Addr) -> Self
Constructs a new SockAddrStorage from an Ipv6Addr object.
Sourcepub fn to_socket_addr(&self) -> Option<SocketAddr>
pub fn to_socket_addr(&self) -> Option<SocketAddr>
Converts the SockAddrStorage to a std::net::SocketAddr if it contains a valid IPv4 or IPv6 address.
Sourcepub fn to_string(&self) -> Option<String>
pub fn to_string(&self) -> Option<String>
Converts the SockAddrStorage to a String representation of the IP address and port.
Sourcepub fn to_wide_string(&self) -> Option<String>
pub fn to_wide_string(&self) -> Option<String>
Converts the SockAddrStorage to a wide String representation of the IP address and port.
Trait Implementations§
Source§impl Clone for SockAddrStorage
impl Clone for SockAddrStorage
Source§fn clone(&self) -> SockAddrStorage
fn clone(&self) -> SockAddrStorage
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SockAddrStorage
impl Debug for SockAddrStorage
Source§impl Default for SockAddrStorage
impl Default for SockAddrStorage
Source§impl From<SockAddrStorage> for IpAddr
impl From<SockAddrStorage> for IpAddr
Source§fn from(ip_address_info: SockAddrStorage) -> Self
fn from(ip_address_info: SockAddrStorage) -> Self
Source§impl PartialEq for SockAddrStorage
impl PartialEq for SockAddrStorage
impl Copy for SockAddrStorage
impl Eq for SockAddrStorage
impl StructuralPartialEq for SockAddrStorage
Auto Trait Implementations§
impl Freeze for SockAddrStorage
impl RefUnwindSafe for SockAddrStorage
impl Send for SockAddrStorage
impl Sync for SockAddrStorage
impl Unpin for SockAddrStorage
impl UnwindSafe for SockAddrStorage
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)