diff --git a/src/error.rs b/src/error.rs index 23426044f..40bb1cedc 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,6 +1,15 @@ use std::io; use nix::errno::{SysError, EAGAIN}; +use self::MioErrorKind::{ + Eof, + BufUnderflow, + BufOverflow, + WouldBlock, + EventLoopTerminated, + OtherError +}; + pub type MioResult = Result; #[deriving(Show, PartialEq, Clone)] diff --git a/src/io.rs b/src/io.rs index 7db30cfcc..6dd5b153e 100644 --- a/src/io.rs +++ b/src/io.rs @@ -2,6 +2,8 @@ use buf::{Buf, MutBuf}; use os; use error::MioResult; +use self::NonBlock::{Ready, WouldBlock}; + #[deriving(Show)] pub enum NonBlock { Ready(T), diff --git a/src/net.rs b/src/net.rs index bd66aef36..f353d8db4 100644 --- a/src/net.rs +++ b/src/net.rs @@ -1,5 +1,5 @@ use std::fmt; -use std::from_str::FromStr; +use std::str::FromStr; use std::io::net::ip::SocketAddr as StdSocketAddr; use io::{IoHandle, NonBlock}; use error::MioResult; @@ -10,6 +10,9 @@ pub use std::io::net::ip::{IpAddr, Port}; pub use std::io::net::ip::Ipv4Addr as IPv4Addr; pub use std::io::net::ip::Ipv6Addr as IPv6Addr; +use self::SockAddr::{InetAddr,UnixAddr}; +use self::AddressFamily::{Unix,Inet,Inet6}; + pub trait Socket : IoHandle { fn linger(&self) -> MioResult { os::linger(self.desc()) @@ -129,8 +132,11 @@ pub mod tcp { use error::MioResult; use buf::{Buf, MutBuf}; use io; - use io::{IoHandle, IoAcceptor, IoReader, IoWriter, NonBlock, Ready, WouldBlock}; - use net::{AddressFamily, Socket, SockAddr, Inet, Inet6, Stream}; + use io::{IoHandle, IoAcceptor, IoReader, IoWriter, NonBlock}; + use io::NonBlock::{Ready, WouldBlock}; + use net::{AddressFamily, Socket, SockAddr}; + use net::SocketType::Stream; + use net::AddressFamily::{Inet, Inet6}; #[deriving(Show)] pub struct TcpSocket { @@ -237,8 +243,11 @@ pub mod udp { use os; use error::MioResult; use buf::{Buf, MutBuf}; - use io::{IoHandle, IoReader, IoWriter, NonBlock, Ready, WouldBlock}; - use net::{AddressFamily, Socket, MulticastSocket, SockAddr, Inet, Dgram}; + use io::{IoHandle, IoReader, IoWriter, NonBlock}; + use io::NonBlock::{Ready, WouldBlock}; + use net::{AddressFamily, Socket, MulticastSocket, SockAddr}; + use net::SocketType::Dgram; + use net::AddressFamily::Inet; use super::UnconnectedSocket; #[deriving(Show)] diff --git a/src/os/posix.rs b/src/os/posix.rs index df00a75af..0f4d2a9a3 100644 --- a/src/os/posix.rs +++ b/src/os/posix.rs @@ -1,6 +1,10 @@ use std::mem; +use std::num::Int; use error::{MioResult, MioError}; -use net::{AddressFamily, Inet, Inet6, SockAddr, InetAddr, IPv4Addr, SocketType, Dgram, Stream}; +use net::{AddressFamily, SockAddr, IPv4Addr, SocketType}; +use net::SocketType::{Dgram, Stream}; +use net::SockAddr::InetAddr; +use net::AddressFamily::{Inet, Inet6}; pub use std::io::net::ip::IpAddr; mod nix { diff --git a/src/timer.rs b/src/timer.rs index 27c7feddc..d21eb9f85 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -6,6 +6,8 @@ use time::precise_time_ns; use token::Token; use util::Slab; +use self::TimerErrorKind::TimerOverflow; + const EMPTY: Token = Token(uint::MAX); const NS_PER_MS: u64 = 1_000_000; diff --git a/src/util/slab.rs b/src/util/slab.rs index 5c8712737..88f3842dc 100644 --- a/src/util/slab.rs +++ b/src/util/slab.rs @@ -1,4 +1,5 @@ use std::{mem, ptr, int}; +use std::num::Int; use alloc::heap; use token::Token; @@ -36,7 +37,7 @@ impl Slab { // - Use a power of 2 capacity // - Ensure that mem size is less than uint::MAX - let size = cap.checked_mul(&mem::size_of::>()) + let size = cap.checked_mul(mem::size_of::>()) .expect("capacity overflow"); let ptr = unsafe { heap::allocate(size, mem::min_align_of::>()) }; diff --git a/test/test_close_on_drop.rs b/test/test_close_on_drop.rs index 356866e9c..0846ddea7 100644 --- a/test/test_close_on_drop.rs +++ b/test/test_close_on_drop.rs @@ -4,6 +4,8 @@ use mio::net::*; use mio::net::tcp::*; use super::localhost; +use self::TestState::{Initial, AfterRead, AfterHup}; + type TestEventLoop = EventLoop; #[deriving(Show, PartialEq)] diff --git a/test/test_timer.rs b/test/test_timer.rs index d9ab85348..83cd50477 100644 --- a/test/test_timer.rs +++ b/test/test_timer.rs @@ -4,6 +4,8 @@ use mio::net::*; use mio::net::tcp::*; use super::localhost; +use self::TestState::{Initial, AfterHup, AfterRead}; + type TestEventLoop = EventLoop; const SERVER: Token = Token(0);