From 6370f2978e485fd46bcb64f51a1c003395acfedc Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 26 Mar 2015 16:18:29 -0700 Subject: 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] --- src/libstd/sys/common/net2.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/libstd/sys/common') diff --git a/src/libstd/sys/common/net2.rs b/src/libstd/sys/common/net2.rs index e213a86644f..8b54b7e6fb4 100644 --- a/src/libstd/sys/common/net2.rs +++ b/src/libstd/sys/common/net2.rs @@ -222,6 +222,12 @@ impl TcpStream { } } +impl FromInner for TcpStream { + fn from_inner(socket: Socket) -> TcpStream { + TcpStream { inner: socket } + } +} + //////////////////////////////////////////////////////////////////////////////// // TCP listeners //////////////////////////////////////////////////////////////////////////////// @@ -275,6 +281,12 @@ impl TcpListener { } } +impl FromInner for TcpListener { + fn from_inner(socket: Socket) -> TcpListener { + TcpListener { inner: socket } + } +} + //////////////////////////////////////////////////////////////////////////////// // UDP //////////////////////////////////////////////////////////////////////////////// @@ -387,3 +399,9 @@ impl UdpSocket { self.inner.duplicate().map(|s| UdpSocket { inner: s }) } } + +impl FromInner for UdpSocket { + fn from_inner(socket: Socket) -> UdpSocket { + UdpSocket { inner: socket } + } +} -- cgit 1.4.1-3-g733a5