Expand description
This crate exposes a common interface to in_addr between Unix and Windows.
There are two types in this crate.
in_addr, a type alias to the platform specific version of this type. Use this in the signature ofexternfunctions.InAddr, a newtype wrapper aroundin_addr. It implements conversions to and fromu32,std::net::Ipv4Addr, andin_addr.
§Example
extern {
fn inet_ntoa(addr: *const in_addr::in_addr) -> *const std::os::raw::c_char;
}
fn main() {
let addr = in_addr::InAddr::new(std::net::Ipv4Addr::LOCALHOST);
let addr_text = unsafe { std::ffi::CStr::from_ptr(inet_ntoa(&addr.into())) };
println!("The address is {}.", addr_text.to_string_lossy());
}Structs§
- InAddr
- Wrapper around
in_addron whichFromis implemented.
Type Aliases§
- in_addr
- Type alias to the Unix version of
in_addr.