[][src]Crate in_addr

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 of extern functions.
  • InAddr, a newtype wrapper around in_addr. It implements conversions to and from u32, std::net::Ipv4Addr, and in_addr.


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());



Wrapper around in_addr on which From is implemented.

Type Definitions


Type alias to the Unix version of in_addr.