Description
As mentioned in the RFC, migration to I/O safety will be a gradual process. I'm laying out a roadmap here, with todo items, to help organize the process. If anyone is interested in helping with any of the items in this process, has ideas of things we should add, or has any questions about anything, please post in this issue! I'll add names to the todo items to track who's working on what.
The first steps are:
- Land the I/O safety stabilization PR (@sunfishcode)
- Update io-lifetimes' API to match what's being stabilized: io-lifetimes 0.7.2 (@sunfishcode)
- Wait for I/O safety to make it to stable Rust, ETA Rust 1.63 on August 11 (rust-lang ;-))
Once the feature reaches stable, the next step will be to contribute AsFd
, From<OwnedFd>
and From<T> for OwnedFd
impls to popular types in the ecosystem. These changes are semver compatible, though they do have MSRV considerations.
- std already has impls for all its own types.
- I'll migrate crates I maintain:
- cap-std (@sunfishcode)
- io-streams (@sunfishcode)
- io-extras (@sunfishcode)
- We'll want to contribute impls to upstream crates for the types that io-lifetimes has impls for; these can follow the implementations in
impls_*.rs
files in the src directory.- async-std (Implement I/O-safe traits on types async-rs/async-std#1036) (released in 1.13)
- fs-err (Implement I/O safety traits andrewhickman/fs-err#39)
- mio (Migrate to I/O safety traits tokio-rs/mio#1588; msrv bump is now done)
- os_pipe (Implement I/O safety traits oconnor663/os_pipe.rs#25)
- tokio
- socket2 (Implement the I/O-safety traits for Socket and SockRef rust-lang/socket2#325; released in 0.5)
- async-net (Add I/O-safe traits smol-rs/async-net#21)
- There are likely other crates beyond what io-lifetimes happened to add impls for. If a type implements
AsRawFd
,FromRawFd
, and/orIntoRawFd
, it usually wantsAsFd
,From<OwnedFd>
, and/orFrom<T> for OwnedFd
, respectively. And similar for Windows withHandle
andSocket
in forFd
.- TODO: add others here
To help crates that are already using io-lifetimes, such as rustix:
- Update io-lifetimes to re-export std's types and traits by default when they're available in a stable rustc. (@sunfishcode) (Update for io_safety being stabilized. #41)
Once "enough" popular types have added the new impls, we can start migrating APIs to use the new traits, such as using AsFd
in place of AsRawFd
. When doing so, any functions that accept raw file-descriptor arguments should be changed to unsafe as well. These changes may require a semver bump. They may require a Minimum Supported Rust Version bump too, though another option is to use io-lifetimes once the change to have it re-export std's types and traits by default lands.
- fd-lock (@sunfishcode) (Use the new I/O safety traits, using rustix yoshuawuyts/fd-lock#14)
- terminal_size (Update the API for I/O safety eminence/terminal-size#66)
- TODO: add others here