From beb14d013fdeb69ee1178e9428e0ceae5b76f58c Mon Sep 17 00:00:00 2001 From: Evgeny Rozaliev Date: Wed, 19 Nov 2014 15:43:03 +0300 Subject: [PATCH 1/3] [fix] import path for FromStr --- src/net.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net.rs b/src/net.rs index bd66aef36..ae08a8386 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; From 5b1010d3a7c3728b800cb7df4e1c74778a01877d Mon Sep 17 00:00:00 2001 From: Evgeny Rozaliev Date: Wed, 19 Nov 2014 16:09:56 +0300 Subject: [PATCH 2/3] Reexport enums variants With https://github.com/rust-lang/rust/pull/18973 merged enum variants are namespaced. They should be reexported or used like Enum::Variant. --- src/error.rs | 9 +++++++++ src/io.rs | 2 ++ src/net.rs | 17 +++++++++++++---- src/os/posix.rs | 5 ++++- src/timer.rs | 2 ++ test/test_close_on_drop.rs | 2 ++ test/test_timer.rs | 2 ++ 7 files changed, 34 insertions(+), 5 deletions(-) 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 ae08a8386..f353d8db4 100644 --- a/src/net.rs +++ b/src/net.rs @@ -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..05751212c 100644 --- a/src/os/posix.rs +++ b/src/os/posix.rs @@ -1,6 +1,9 @@ use std::mem; 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/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); From 3173b833cfc6e1c885a8ea2c5f2038b779e8e9ae Mon Sep 17 00:00:00 2001 From: Evgeny Rozaliev Date: Wed, 19 Nov 2014 16:19:20 +0300 Subject: [PATCH 3/3] Import num::Int --- src/os/posix.rs | 1 + src/util/slab.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/os/posix.rs b/src/os/posix.rs index 05751212c..0f4d2a9a3 100644 --- a/src/os/posix.rs +++ b/src/os/posix.rs @@ -1,4 +1,5 @@ use std::mem; +use std::num::Int; use error::{MioResult, MioError}; use net::{AddressFamily, SockAddr, IPv4Addr, SocketType}; use net::SocketType::{Dgram, Stream}; 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::>()) };