5 releases (1 stable)
1.0.0 | Feb 15, 2019 |
---|---|
0.2.0 | Feb 14, 2019 |
0.1.2 | Feb 13, 2019 |
0.1.1 | Feb 13, 2019 |
0.1.0 | Feb 13, 2019 |
#8 in #addr
Used in ei-sys
6KB
78 lines
in_addr
This crate exposes a common interface to in_addr between Unix and Windows. Get rid of these #[cfg]
s!
Features
no-std
: Compile this crate withno_std
. Conversions to and fromstd::net::Ipv4Addr
will not be available.
Documentation
lib.rs
:
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 ofextern
functions.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());
}
Dependencies
~215KB