Use the new I/O safety traits, using rustix#14
Use the new I/O safety traits, using rustix#14sunfishcode merged 1 commit intoyoshuawuyts:masterfrom
Conversation
|
As a datapoint, rustyline is a popular user of fd-lock, and it builds and runs all its tests successfully, using fd-lock from this branch and no other changes. The complete patch is sunfishcode/rustyline@a6124cf. |
|
As another datapoint, cargo-spellcheck is another popular user of fd-lock. Porting it to this branch just involved updating it to fd-lock 3, and explicitly enabling the "fs-err" feature in io-lifetimes, which adds The complete patch is sunfishcode/cargo-spellcheck@f5ddd8e. Once |
yoshuawuyts
left a comment
There was a problem hiding this comment.
This looks amazing! Thank you so much!
|
@sunfishcode I've invited you as an owner of both the git repo, and the crate on crates.io. Feel free to merge this and publish a new major if and when you think it's ready! |
|
My thought here was to wait until If we land it as-is, some users will have to add an explicit dependency on io-lifetimes to enable the features they need, as the cargo-spellcheck example above does. We could avoid that if we submit |
|
I've now added a mode to io-lifetimes to use the new std types and traits on nightly. fd-lock's and rustyline's tests pass under this mode. cargo-spellcheck needs |
7dd3692 to
79a4aaa
Compare
Use rustix instead of calling libc directly, which factors out several unsafe blocks and simplifies error handling. There is still one `unsafe` block needed, to dereference raw file descriptors passed in from the user, since the crate still uses `AsRawFd`. Once I/O safety is stablized in std, this crate can switch to using `AsFd`, which will eliminate the last `unsafe` block. This splits out just the API-compatible parts of yoshuawuyts#14. It does not include the changes to use the `AsFd` trait in the public API, so it's not an API-breaking change.
Use rustix instead of calling libc directly, which factors out several unsafe blocks and simplifies error handling. There is still one `unsafe` block needed, to dereference raw file descriptors passed in from the user, since the crate still uses `AsRawFd`. Once I/O safety is stablized in std, this crate can switch to using `AsFd`, which will eliminate the last `unsafe` block. This splits out just the API-compatible parts of yoshuawuyts#14. It does not include the changes to use the `AsFd` trait in the public API, so it's not an API-breaking change.
4bb9c47 to
ffe6c1f
Compare
Use rustix instead of calling libc directly, which factors out several unsafe blocks and simplifies error handling. There is still one `unsafe` block needed, to dereference raw file descriptors passed in from the user, since the crate still uses `AsRawFd`. Once I/O safety is stablized in std, this crate can switch to using `AsFd`, which will eliminate the last `unsafe` block. This splits out just the API-compatible parts of yoshuawuyts#14. It does not include the changes to use the `AsFd` trait in the public API, so it's not an API-breaking change.
Use rustix instead of calling libc directly, which factors out several unsafe blocks and simplifies error handling. There is still one `unsafe` block needed, to dereference raw file descriptors passed in from the user, since the crate still uses `AsRawFd`. Once I/O safety is stablized in std, this crate can switch to using `AsFd`, which will eliminate the last `unsafe` block. This splits out just the API-compatible parts of #14. It does not include the changes to use the `AsFd` trait in the public API, so it's not an API-breaking change.
|
This is now rebased on #21, so now the diff just contains the |
ef50e21 to
36bd2ce
Compare
edede02 to
49cad23
Compare
ce8f5a2 to
1e84fe2
Compare
39e84e0 to
4a4098f
Compare
|
If I understand correctly, the I/O safety traits are stabilized for a Rust 1.63 release? Will this become ready for merging and a release of |
|
When io_safety lands on stable, the next step I'm picturing is to start contributing I've now posted a roadmap for how I envision this process working: sunfishcode/io-lifetimes#38 |
3dce132 to
0a48ede
Compare
|
fs-err as of version 2.8.0 has This changes APIs using |
Switch public APIs from `AsRawFd`/`AsRawHandle` to the new I/O safety traits `AsFd`/`AsHandle`. On Unix platforms, use rustix to avoid manipulating raw file descriptors altogether.
|
This is now released in fd-lock 4.0.0. |
This implements the idea in #12.
Switch public APIs from
AsRawFd/AsRawHandleto the new I/O safetytraits
AsFd/AsHandle. On Unix platforms, userustixto avoidmanipulating raw file descriptors altogether.
This uses
AsFdandAsHandlefrom theio-lifetimescrate, which areidentical to traits which will hopefully be landing in libstd soon.