about summary refs log tree commit diff
path: root/src/libnative/io/util.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-06-04 00:00:49 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-06-06 22:19:57 -0700
commit51348b068b88d71426d9de93762575cd2bb9a5f5 (patch)
tree14ad616076bf9f670aac893d4c24232e94612c74 /src/libnative/io/util.rs
parentda2293c6f6ea9291749f51a4608d50585be835f0 (diff)
downloadrust-51348b068b88d71426d9de93762575cd2bb9a5f5.tar.gz
rust-51348b068b88d71426d9de93762575cd2bb9a5f5.zip
native: Deal with the rtio changes
Diffstat (limited to 'src/libnative/io/util.rs')
-rw-r--r--src/libnative/io/util.rs37
1 files changed, 30 insertions, 7 deletions
diff --git a/src/libnative/io/util.rs b/src/libnative/io/util.rs
index fe7a58a5e68..a3c5349fa45 100644
--- a/src/libnative/io/util.rs
+++ b/src/libnative/io/util.rs
@@ -9,11 +9,10 @@
 // except according to those terms.
 
 use libc;
-use std::io::IoResult;
-use std::io;
 use std::mem;
 use std::os;
 use std::ptr;
+use std::rt::rtio::{IoResult, IoError};
 
 use super::c;
 use super::net;
@@ -25,10 +24,30 @@ pub enum SocketStatus {
     Writable,
 }
 
-pub fn timeout(desc: &'static str) -> io::IoError {
-    io::IoError {
-        kind: io::TimedOut,
-        desc: desc,
+pub fn timeout(desc: &'static str) -> IoError {
+    #[cfg(unix)] use ERROR = libc::ETIMEDOUT;
+    #[cfg(windows)] use ERROR = libc::ERROR_OPERATION_ABORTED;
+    IoError {
+        code: ERROR as uint,
+        extra: 0,
+        detail: Some(desc.to_str()),
+    }
+}
+
+pub fn short_write(n: uint, desc: &'static str) -> IoError {
+    #[cfg(unix)] use ERROR = libc::EAGAIN;
+    #[cfg(windows)] use ERROR = libc::ERROR_OPERATION_ABORTED;
+    IoError {
+        code: ERROR as uint,
+        extra: n,
+        detail: Some(desc.to_str()),
+    }
+}
+
+pub fn eof() -> IoError {
+    IoError {
+        code: libc::EOF as uint,
+        extra: 0,
         detail: None,
     }
 }
@@ -100,7 +119,11 @@ pub fn connect_timeout(fd: net::sock_t,
                     if err == 0 {
                         Ok(())
                     } else {
-                        Err(io::IoError::from_errno(err as uint, true))
+                        Err(IoError {
+                            code: err as uint,
+                            extra: 0,
+                            detail: Some(os::error_string(err as uint)),
+                        })
                     }
                 }
             }