Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for io_safety being stabilized. #41

Merged
merged 8 commits into from
Aug 16, 2022

Conversation

sunfishcode
Copy link
Owner

io_safety is now stable in Rust 1.63! This PR updates io-lifetimes to
use the standard library types and traits when available, and use its
own types and traits on older Rust versions.

The traits FromFd and IntoFd are now marked as deprecated. These are
replaced by From<OwnedFd> and From<...> for OwnedFd in the standard
library, and users should migrate accordingly.

io_safety is now [stable in Rust 1.63]! This PR updates io-lifetimes to
use the standard library types and traits when available, and use its
own types and traits on older Rust versions.

The traits `FromFd` and `IntoFd` are now marked as deprecated. These are
replaced by `From<OwnedFd>` and `From<...> for OwnedFd` in the standard
library, and users should migrate accordingly.

[stable in Rust 1.63]: https://blog.rust-lang.org/2022/08/11/Rust-1.63.0.html#rust-ownership-for-raw-file-descriptorshandles-io-safety
And, migrate the portability types and traits to use `From<OwnedFd>`
and `Into<OwnedFd>`.
This allows the `from_into_fd` extension to continue working, for now.
@sunfishcode
Copy link
Owner Author

This will be a semver-incompatible change. And since the main types and traits are stablized now, I think it makes sense to make this a 1.0 release.

Copy link

@notgull notgull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, this is getting exciting

src/traits.rs Outdated
@@ -102,6 +102,10 @@ pub trait IntoHandle {
/// let owned_handle: OwnedHandle = f.into_handle();
/// # Ok::<(), io::Error>(())
/// ```
#[deprecated(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should a deprecation notice be attached to the traits as well?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot, yes, we can deprecate IntoFd and related traits.

I didn't mark FromFd and friends as deprecated yet, because they have the from_into_fd utility functions, which some users use and find handy. Fortunately, it's just a blanket impl for any type that implements From<OwnedFd>, so it's not something users need to implement themselves.

@sunfishcode sunfishcode merged commit 170df73 into main Aug 16, 2022
@sunfishcode sunfishcode deleted the sunfishcode/stable-io-safety branch August 16, 2022 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants