Skip to content

Commit

Permalink
Track Rust nightlies
Browse files Browse the repository at this point in the history
  • Loading branch information
carllerche committed Mar 19, 2015
1 parent 1e9c7b2 commit 2b60633
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub use self::consts::*;
pub use self::ffi::flock;

// Re-export Fd defined in std
pub type Fd = ::std::os::unix::Fd;
pub type Fd = ::std::os::unix::io::Fd;

#[allow(dead_code)]
mod ffi {
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! defined in.
#![crate_name = "nix"]

#![feature(collections, core, net, linkage, libc, std_misc)]
#![feature(collections, core, io_ext, linkage, libc, std_misc)]
#![allow(non_camel_case_types)]

#[macro_use]
Expand Down Expand Up @@ -51,7 +51,7 @@ pub mod unistd;
*/

use std::ffi::OsStr;
use std::os::unix::OsStrExt;
use std::os::unix::ffi::OsStrExt;

/// Converts a value to an external (FFI) string representation
trait AsExtStr {
Expand Down
2 changes: 1 addition & 1 deletion src/nix.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use libc;
use std::ffi::{OsStr, AsOsStr};
use std::os::unix::OsStrExt;
use std::os::unix::ffi::OsStrExt;
use std::path::{Path, PathBuf};
use std::slice::bytes;

Expand Down
27 changes: 23 additions & 4 deletions src/sys/socket/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use std::{fmt, hash, mem, net, ptr};
use std::ffi::{CStr, OsStr};
use std::num::Int;
use std::path::Path;
use std::os::unix::OsStrExt;
use std::os::unix::ffi::OsStrExt;

// TODO: uncomment out IpAddr functions: rust-lang/rfcs#988

/*
*
Expand All @@ -30,7 +32,12 @@ pub enum InetAddr {

impl InetAddr {
pub fn from_std(std: &net::SocketAddr) -> InetAddr {
InetAddr::new(IpAddr::from_std(&std.ip()), std.port())
let ip = match *std {
net::SocketAddr::V4(ref addr) => IpAddr::V4(Ipv4Addr::from_std(&addr.ip())),
net::SocketAddr::V6(ref addr) => IpAddr::V6(Ipv6Addr::from_std(&addr.ip())),
};

InetAddr::new(ip, std.port())
}

pub fn new(ip: IpAddr, port: u16) -> InetAddr {
Expand All @@ -53,7 +60,6 @@ impl InetAddr {
}
}
}

/// Gets the IP address associated with this socket address.
pub fn ip(&self) -> IpAddr {
match *self {
Expand All @@ -71,7 +77,18 @@ impl InetAddr {
}

pub fn to_std(&self) -> net::SocketAddr {
net::SocketAddr::new(self.ip().to_std(), self.port())
match *self {
InetAddr::V4(ref sa) => net::SocketAddr::V4(
net::SocketAddrV4::new(
Ipv4Addr(sa.sin_addr).to_std(),
self.port())),
InetAddr::V6(ref sa) => net::SocketAddr::V6(
net::SocketAddrV6::new(
Ipv6Addr(sa.sin6_addr).to_std(),
self.port(),
sa.sin6_flowinfo,
sa.sin6_scope_id)),
}
}

pub fn to_str(&self) -> String {
Expand Down Expand Up @@ -160,6 +177,7 @@ impl IpAddr {
IpAddr::V6(Ipv6Addr::new(a, b, c, d, e, f, g, h))
}

/*
pub fn from_std(std: &net::IpAddr) -> IpAddr {
match *std {
net::IpAddr::V4(ref std) => IpAddr::V4(Ipv4Addr::from_std(std)),
Expand All @@ -173,6 +191,7 @@ impl IpAddr {
IpAddr::V6(ref ip) => net::IpAddr::V6(ip.to_std()),
}
}
*/
}

impl fmt::Display for IpAddr {
Expand Down
2 changes: 1 addition & 1 deletion src/sys/socket/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use errno::Errno;
use sys::time::TimeVal;
use libc::{c_int, uint8_t, c_void, socklen_t};
use std::mem;
use std::os::unix::Fd;
use std::os::unix::io::Fd;

// Helper to generate the sockopt accessors
// TODO: Figure out how to ommit gets when not supported by opt
Expand Down
2 changes: 1 addition & 1 deletion test/sys/test_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{mem, net};
use std::num::Int;
use std::path::Path;
use std::str::FromStr;
use std::os::unix::AsRawFd;
use std::os::unix::io::AsRawFd;
use ports::localhost;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion test/test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(core, libc, net, std_misc)]
#![feature(core, io_ext, libc)]

extern crate nix;
extern crate libc;
Expand Down

0 comments on commit 2b60633

Please sign in to comment.