Skip to content

I/O safety.#87329

Merged
bors merged 28 commits intorust-lang:masterfrom
sunfishcode:sunfishcode/io-safety
Aug 20, 2021
Merged

I/O safety.#87329
bors merged 28 commits intorust-lang:masterfrom
sunfishcode:sunfishcode/io-safety

Conversation

@sunfishcode
Copy link
Copy Markdown
Member

Introduce OwnedFd and BorrowedFd, and the AsFd trait, and
implementations of AsFd, From<OwnedFd> and From<T> for OwnedFd
for relevant types, along with Windows counterparts for handles and
sockets.

Tracking issue: #87074

RFC: https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md

Highlights:

  • The doc comments at the top of library/std/src/os/unix/io/mod.rs and library/std/src/os/windows/io/mod.rs
  • The new types and traits in library/std/src/os/unix/io/fd.rs and library/std/src/os/windows/io/handle.rs
  • The removal of the RawHandle struct the Windows impl, which had the same name as the RawHandle type alias, and its functionality is now folded into Handle.

Managing five levels of wrapping (File wraps sys::fs::File wraps sys::fs::FileDesc wraps OwnedFd wraps RawFd, etc.) made for a fair amount of churn and verbose as/into/from sequences in some places. I've managed to simplify some of them, but I'm open to ideas here.

r? @joshtriplett

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-io Area: `std::io`, `std::fs`, `std::net` and `std::path` merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.