summaryrefslogtreecommitdiffhomepage
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 4db3923..fe086c1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2,9 +2,9 @@
#![cfg(target_os = "linux")]
-extern crate errno;
extern crate libc;
+use std::io;
use std::marker::PhantomData;
use std::mem;
use std::net::*;
@@ -42,11 +42,11 @@ struct IfaddrHandle {
struct IfaddrIter<'a>(*const libc::ifaddrs, PhantomData<&'a libc::ifaddrs>);
impl IfaddrHandle {
- fn new() -> Result<IfaddrHandle, errno::Errno> {
+ fn new() -> io::Result<IfaddrHandle> {
let mut addrs: *mut libc::ifaddrs = unsafe { mem::uninitialized() };
match unsafe { libc::getifaddrs(&mut addrs as *mut *mut libc::ifaddrs) } {
0 => Ok(IfaddrHandle{addrs: addrs, marker: PhantomData}),
- _ => Err(errno::errno()),
+ _ => Err(io::Error::last_os_error()),
}
}
@@ -124,13 +124,13 @@ fn copy_name(name: *const c_char) -> Vec<u8> {
/// ```
/// let lo = getifaddrs::getifaddrs().unwrap().into_iter().filter(|i| { i.index == 1 });
/// ```
-pub fn getifaddrs() -> Result<Vec<IfAddr>, errno::Errno> {
+pub fn getifaddrs() -> io::Result<Vec<IfAddr>> {
IfaddrHandle::new().and_then(|addrs| {
let mut result = Vec::new();
for ifaddr in addrs.iter() {
let index = match unsafe { libc::if_nametoindex(ifaddr.ifa_name) } {
- 0 => return Err(errno::errno()),
+ 0 => return Err(io::Error::last_os_error()),
i => i,
};