Struct ndisapi_rs::SockAddrStorage
source · 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 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<SockAddrStorage> for SockAddrStorage
impl PartialEq<SockAddrStorage> for SockAddrStorage
source§fn eq(&self, other: &SockAddrStorage) -> bool
fn eq(&self, other: &SockAddrStorage) -> bool
self
and other
values to be equal, and is used
by ==
.