5 个版本 (1 个稳定版)
| 1.0.0 | 2019年2月15日 |
|---|---|
| 0.2.0 | 2019年2月14日 |
| 0.1.2 | 2019年2月13日 |
| 0.1.1 | 2019年2月13日 |
| 0.1.0 | 2019年2月13日 |
#8 在 #地址
用于 ei-sys
6KB
78 行
in_addr
该软件包在Unix和Windows之间公开了in_addr的通用接口。摆脱这些 #[cfg]!
特性
无需std:使用no_std编译此软件包。不会提供从和到std::net::Ipv4Addr的转换。
文档
lib.rs:
该软件包在Unix和Windows之间公开了in_addr的通用接口。
该软件包中有两种类型。
in_addr,此类类型的平台特定版本的别称。在extern函数的签名中使用此类型。InAddr,围绕in_addr的新类型包装器。它实现了到和从u32、std::net::Ipv4Addr以及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());
}
依赖关系
~215KB