summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authordhivael <dhivael.git@eno.space>2017-06-04 02:03:23 +0200
committerdhivael <dhivael.git@eno.space>2017-06-04 02:03:23 +0200
commitb65e18500f5e97609a7ebea86a132b9a1ab87914 (patch)
tree6b95cd5eca5af3c67bae540b041f50e5c4c5085d
parentdf29db681990a8163dda34ee37639300c1859e2a (diff)
drop errno dependencyHEADmaster
turns out, std::io already has an appropriate error type
-rw-r--r--Cargo.toml1
-rw-r--r--src/lib.rs10
2 files changed, 5 insertions, 6 deletions
diff --git a/Cargo.toml b/Cargo.toml
index f3fc836..84d92eb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,4 +5,3 @@ authors = ["dhivael"]
[dependencies]
libc = "0.2.23"
-errno = "0.2.3"
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,
};