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_STORAGE
Implementations§
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 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more