Uh oh!
There was an error while loading. Please reload this page.
std: Stabilize parts of std::os::platform::io - #23766
Conversation
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]rust-highfive
commented
Mar 26, 2015
r? @huonw (rust_highfive has picked a reviewer for you, use r? to override) |
alexcrichton
commented
Mar 26, 2015
r? @aturon |
carllerche
commented
Mar 27, 2015
Probably too late, but would this be better as Edit Changed to |
blaenk
commented
Mar 27, 2015
I agree with @carllerche, unless there are reasons for not going that route that I'm not aware of. Same with |
aturon
commented
Mar 27, 2015
The problem with using the generic traits is that you lose any notion of "opt in" for platform-specific behavior. With traits defined in the platform modules, it's really clear from a |
carllerche
commented
Mar 27, 2015
@aturon Would you not get the "opt in" factor by pulling in the target types, like |
aturon
commented
Mar 27, 2015
It depends partly on the specifics, but it's possible to write something like Regardless, the generic methods are not meant to fully replace named conversion methods; they're intended primarily for generic programming. |
l0kod
commented
Mar 27, 2015
Nice! It may be preferable to be the only owner of a A proper file descriptor ownership passing would save from file descriptor leaking. I prefer a trait-based pattern for The Probably the same for *Handle and *Socket. |
alexcrichton
commented
Mar 27, 2015
I fear that this may be overkill for this low-level method unfortunately. It seems like an extra "safety barrier" which may end up backfiring when you're in a situation like trying to get a file descriptor out of an
I fear that this is also perhaps too generalized for this use case. The trait is intended to represent the minimal step of construction from a file descriptor to an I/O object. It is in all cases currently just a noop, which is quite a powerful guarantee. The trait is intended to be an extension trait as well, not necessarily a general purpose trait. Along these lines I don't think we want to implement a conversion from something like I think any form of fallible conversion would also be done through a separate extension trait to clearly document why it may fail and be clear about what's going on. |
l0kod
commented
Mar 28, 2015
Replacing It leave the possibility to create your own |
l0kod
commented
Mar 28, 2015
|
l0kod
commented
Mar 28, 2015
Yes, you can, but only if you really want to. We should avoid |
alexcrichton
commented
Mar 30, 2015
Note that one of the primary points of these apis is that it does take ownership. In general we're not trying to create a one-size-fits-all "create this object from a file descriptor" abstraction, and erring on the side of being conservative is generally the better option for the standard library. Along these lines I think there's a few downsides to the two signatures you've proposed:
In general these APIs are the conservative option here as they are not designed to enable generic programming over |
aturon
commented
Mar 30, 2015
I think we should move forward with this PR. While I agree with @l0kod that we will want to pursue safer abstractions in the long run, this lowest-level API will always have a place. This is part of the reason for shifting to "RawFd" naming everywhere -- we want to leave plenty of room to add a higher-level notion of |
bors
commented
Mar 30, 2015
⌛ Testing commit 6370f29 with merge 0a9618d... |
bors
commented
Mar 31, 2015
💔 Test failed - auto-mac-64-opt |
alexcrichton
commented
Mar 31, 2015
@bors: retry On Mon, Mar 30, 2015 at 5:13 PM, bors notifications@github.com wrote:
|
bors
commented
Mar 31, 2015
⌛ Testing commit 6370f29 with merge fce17ab... |
bors
commented
Mar 31, 2015
💔 Test failed - auto-mac-64-nopt-t |
alexcrichton
commented
Mar 31, 2015
@bors: retry |
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 stabilizes the platform-specific
iomodules, specifically aroundthe 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 fromFd)RawHandle(renamed fromHandle)RawSocket(renamed fromSocket)AsRaw{Fd,Socket,Handle}implementationsstd::os::{unix, windows}::ioThe following material was added as
#[unstable]:FromRaw{Fd,Socket,Handle}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:
IntoRawXXXtraits to consume the raw representation and cancel theauto-destructor.
Fd,Socket, andHandleabstractions that behave like Rust objects andhave 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
Rawin from of thetype aliases in each of the platform-specific modules.
[breaking-change]