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

Implement FromRawFd & FromRawHandle for File #2792

Merged
merged 1 commit into from Aug 28, 2020

Conversation

nvzqz
Copy link
Contributor

@nvzqz nvzqz commented Aug 25, 2020

Motivation

These traits make it simpler to create instances from the raw OS primitives.

Solution

Defer to the trait implementations in std and convert from the resulting std::fs::File.


#[cfg(windows)]
impl std::os::windows::io::FromRawHandle for File {
unsafe fn from_raw_handle(handle: std::os::windows::io::RawHandle) -> Self {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line is exactly 80 columns 😄

@nvzqz nvzqz force-pushed the fs-fromraw branch 2 times, most recently from 582aa4c to 1cfedba Compare August 25, 2020 01:00
@Darksonn Darksonn added A-tokio Area: The main tokio crate C-enhancement Category: A PR with an enhancement or bugfix. M-fs Module: tokio/fs labels Aug 26, 2020
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

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

This seems reasonable to me.

Copy link
Member

@hawkw hawkw 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 — i see no obvious reason we can't do this!

@Darksonn Darksonn merged commit 8270774 into tokio-rs:master Aug 28, 2020
@nvzqz nvzqz deleted the fs-fromraw branch August 28, 2020 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-enhancement Category: A PR with an enhancement or bugfix. M-fs Module: tokio/fs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants