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

Impl AsRawFd for tokio::fs::File #1645

Closed
wants to merge 1 commit into from

Conversation

film42
Copy link

@film42 film42 commented Oct 10, 2019

Hey! This is my first open source rust PR to a major project, so please let me know if anything looks wrong, or if there's a better practice to implement this!

There are cases where a user may want to grab the underlying fd of a
tokio::fs::File, example: if a user wanted to use a non-blocking splice
copy to the file, they would need to be able to pull out the RawFd.
Since std::fs::File implements this, it seems like a safe thing to
expose from tokio::fs::File.

Motivation

I was implementing a non-blocking splice copy, but found that tokio::fs::File does not implement AsRawFd which was surprising since std::fs::File implements this. I thought it would be nice to add here as well.

Solution

The solution is pretty easy since the underlying std File type already implements this.

There are cases where a user may want to grab the underlying fd of a
tokio::fs::File, example: if a user wanted to use a non-blocking splice
copy to the file, they would need to be able to pull out the RawFd.
Since std::fs::File implements this, it seems like a safe thing to
expose from tokio::fs::File.
@film42
Copy link
Author

film42 commented Oct 10, 2019

Whoops, just saw #1640 already implements this and is waiting for a review. I'll close this one.

@film42 film42 closed this Oct 10, 2019
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.

None yet

1 participant