@@ -99,6 +99,39 @@ is what motivates having `BorrowedFd` instead of just using `&OwnedFd`.
9999Note the use of ` Option<OwnedFd> ` as the return value of ` open ` , representing
100100the fact that it can either succeed or fail.
101101
102+ ## I/O Safety in Rust Nightly
103+
104+ The I/O Safety
105+ [ implementation PR] ( https://github.com/rust-lang/rust/pull/87329 ) has now
106+ landed and is available on Rust Nightly. It can be used directly, or through
107+ io-lifetimes: when ` io_lifetimes_use_std ` mode is enabled, io-lifetimes uses
108+ the std's ` OwnedFd ` , ` BorrowedFd ` , and ` AsFd ` instead of defining its own.
109+
110+ To enable ` io_lifetimes_use_std ` mode:
111+ - Set the environment variable ` RUSTFLAGS=--cfg=io_lifetimes_use_std ` , and
112+ - add ` #![cfg_attr(io_lifetimes_use_std, feature(io_safety))] ` to your
113+ lib.rs or main.rs.
114+
115+ Note that, unfortunately, ` io_lifetimes_use_std ` mode doesn't support the
116+ optional impls for third-party crates.
117+
118+ The code in ` std ` uses ` From<OwnedFd> ` and ` Into<OwnedFd> ` instead of ` FromFd `
119+ and ` IntoFd ` . io-lifetimes is unable to provide impls for these for third-party
120+ types, so it continues to provide ` FromFd ` and ` IntoFd ` for now, with default
121+ impls that forward to ` From<OwnedFd> ` and ` Into<OwnedFd> ` in
122+ ` io_lifetimes_use_std ` mode.
123+
124+ io-lifetimes also includes several features which are not (yet?) in std,
125+ including the portability traits ` AsFilelike ` /` AsSocketlike ` /etc., the
126+ ` from_into_* ` functions in the ` From* ` traits, and [ views] .
127+
128+ If you test a crate with the std I/O safety types and traits, or io-lifetimes
129+ in ` io_lifetimes_use_std ` mode, please post a note about it in the
130+ [ I/O safety tracking issue] as an example of usage.
131+
132+ [ I/O safety tracking issue ] : https://github.com/rust-lang/rust/issues/87074
133+ [ views ] : https://docs.rs/io-lifetimes/*/io_lifetimes/views/index.html
134+
102135## Prior Art
103136
104137There are several similar crates: [ fd] ( https://crates.io/crates/fd ) ,
0 commit comments