diff --git a/src/fcntl.rs b/src/fcntl.rs index 0a8236a44b..8a88cbc46f 100644 --- a/src/fcntl.rs +++ b/src/fcntl.rs @@ -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 { diff --git a/src/lib.rs b/src/lib.rs index ec3341e779..97676dd9af 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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] @@ -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 { diff --git a/src/nix.rs b/src/nix.rs index f5195c400b..936812edbe 100644 --- a/src/nix.rs +++ b/src/nix.rs @@ -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; diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs index 77a699410c..5ff65594cf 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs @@ -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 /* * @@ -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 { @@ -53,7 +60,6 @@ impl InetAddr { } } } - /// Gets the IP address associated with this socket address. pub fn ip(&self) -> IpAddr { match *self { @@ -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 { @@ -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)), @@ -173,6 +191,7 @@ impl IpAddr { IpAddr::V6(ref ip) => net::IpAddr::V6(ip.to_std()), } } + */ } impl fmt::Display for IpAddr { diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs index bdbe39a829..be3ff8e73f 100644 --- a/src/sys/socket/sockopt.rs +++ b/src/sys/socket/sockopt.rs @@ -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 diff --git a/test/sys/test_socket.rs b/test/sys/test_socket.rs index 6701150a42..d175b693a8 100644 --- a/test/sys/test_socket.rs +++ b/test/sys/test_socket.rs @@ -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] diff --git a/test/test.rs b/test/test.rs index ba66002a2a..c5b8420cc3 100644 --- a/test/test.rs +++ b/test/test.rs @@ -1,4 +1,4 @@ -#![feature(core, libc, net, std_misc)] +#![feature(core, io_ext, libc)] extern crate nix; extern crate libc;