windows-bindgen 0.52.0

Windows metadata compiler
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
impl ::core::convert::From<::std::net::Ipv4Addr> for IN_ADDR {
    fn from(addr: ::std::net::Ipv4Addr) -> Self {
        // u32::from(addr) is in host byte order
        // S_addr must be big-endian, network byte order
        Self { S_un: IN_ADDR_0 { S_addr: u32::from(addr).to_be() } }
    }
}
impl ::core::convert::From<IN_ADDR> for ::std::net::Ipv4Addr {
    fn from(in_addr: IN_ADDR) -> Self {
        // SAFETY: this is safe because the union variants are just views of the same exact data
        // in_addr.S_un.S_addr is big-endian, network byte order
        // Ipv4Addr::new() expects the parameter in host byte order
        Self::from(u32::from_be(unsafe { in_addr.S_un.S_addr }))
    }
}