std: Stabilize parts of std::os::platform::io

This commit stabilizes the platform-specific `io` modules, specifically around
the traits having to do with the raw representation of each object on each
platform.

Specifically, the following material was stabilized:

* `AsRaw{Fd,Socket,Handle}`
* `RawFd` (renamed from `Fd`)
* `RawHandle` (renamed from `Handle`)
* `RawSocket` (renamed from `Socket`)
* `AsRaw{Fd,Socket,Handle}` implementations
* `std::os::{unix, windows}::io`

The following material was added as `#[unstable]`:

* `FromRaw{Fd,Socket,Handle}`
* Implementations for various primitives

There are a number of future improvements that are possible to make to this
module, but this should cover a good bit of functionality desired from these
modules for now. Some specific future additions may include:

* `IntoRawXXX` traits to consume the raw representation and cancel the
  auto-destructor.
* `Fd`, `Socket`, and `Handle` abstractions that behave like Rust objects and
  have nice methods for various syscalls.

At this time though, these are considered backwards-compatible extensions and
will not be stabilized at this time.

This commit is a breaking change due to the addition of `Raw` in from of the
type aliases in each of the platform-specific modules.

[breaking-change]
This commit is contained in:
Alex Crichton
2015-03-26 16:18:29 -07:00
parent 557d4346a2
commit 6370f2978e
11 changed files with 262 additions and 58 deletions

View File

@@ -17,7 +17,7 @@ use io::prelude::*;
use io;
use net::{ToSocketAddrs, SocketAddr, Shutdown};
use sys_common::net2 as net_imp;
use sys_common::AsInner;
use sys_common::{AsInner, FromInner};
/// A structure which represents a TCP stream between a local socket and a
/// remote socket.
@@ -172,6 +172,10 @@ impl AsInner<net_imp::TcpStream> for TcpStream {
fn as_inner(&self) -> &net_imp::TcpStream { &self.0 }
}
impl FromInner<net_imp::TcpStream> for TcpStream {
fn from_inner(inner: net_imp::TcpStream) -> TcpStream { TcpStream(inner) }
}
impl TcpListener {
/// Creates a new `TcpListener` which will be bound to the specified
/// address.
@@ -245,6 +249,12 @@ impl AsInner<net_imp::TcpListener> for TcpListener {
fn as_inner(&self) -> &net_imp::TcpListener { &self.0 }
}
impl FromInner<net_imp::TcpListener> for TcpListener {
fn from_inner(inner: net_imp::TcpListener) -> TcpListener {
TcpListener(inner)
}
}
#[cfg(test)]
mod tests {
use prelude::v1::*;