Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track rust master (enums etc) #54

Merged
merged 3 commits into from
Nov 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
use std::io;
use nix::errno::{SysError, EAGAIN};

use self::MioErrorKind::{
Eof,
BufUnderflow,
BufOverflow,
WouldBlock,
EventLoopTerminated,
OtherError
};

pub type MioResult<T> = Result<T, MioError>;

#[deriving(Show, PartialEq, Clone)]
Expand Down
2 changes: 2 additions & 0 deletions src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use buf::{Buf, MutBuf};
use os;
use error::MioResult;

use self::NonBlock::{Ready, WouldBlock};

#[deriving(Show)]
pub enum NonBlock<T> {
Ready(T),
Expand Down
19 changes: 14 additions & 5 deletions src/net.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<uint> {
os::linger(self.desc())
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)]
Expand Down
6 changes: 5 additions & 1 deletion src/os/posix.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion src/util/slab.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{mem, ptr, int};
use std::num::Int;
use alloc::heap;
use token::Token;

Expand Down Expand Up @@ -36,7 +37,7 @@ impl<T> Slab<T> {
// - Use a power of 2 capacity
// - Ensure that mem size is less than uint::MAX

let size = cap.checked_mul(&mem::size_of::<Entry<T>>())
let size = cap.checked_mul(mem::size_of::<Entry<T>>())
.expect("capacity overflow");

let ptr = unsafe { heap::allocate(size, mem::min_align_of::<Entry<T>>()) };
Expand Down
2 changes: 2 additions & 0 deletions test/test_close_on_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use mio::net::*;
use mio::net::tcp::*;
use super::localhost;

use self::TestState::{Initial, AfterRead, AfterHup};

type TestEventLoop = EventLoop<uint, ()>;

#[deriving(Show, PartialEq)]
Expand Down
2 changes: 2 additions & 0 deletions test/test_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use mio::net::*;
use mio::net::tcp::*;
use super::localhost;

use self::TestState::{Initial, AfterHup, AfterRead};

type TestEventLoop = EventLoop<TcpSocket, ()>;

const SERVER: Token = Token(0);
Expand Down