-
Notifications
You must be signed in to change notification settings - Fork 667
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
Replace RawFd
with IntoRawFd
or AsRawFd
as appropriate
#678
Comments
I think |
I am very much in favor of this. Wouldn't newtype-ing We could have our own newtype'd RawFd, and implement AsRawFd/IntoRawFd/FromRawFd ourselves. Is there a good reason not to do this (other than it being a breaking change) ? |
Integer arithmetic on fd is quite common with IPC and socket passing. If you want a specific concrete usecase, see https://www.freedesktop.org/software/systemd/man/sd_listen_fds.html. In general, I'm in favor of having a more sound |
Well, you could still use Then we'd still have our safe |
@lucab such operation is basically |
What about operations that return RawFd? For example, dup2() returns RawFd, how would one pass that to another function if everything takes AsRawFd? (for example, |
@kahing The interface should be changed to return |
I agree that we should use a Newtype. But we should name it |
@asomers Why don't we just copy directly the private type from |
Would it be worth making an issue on the rust-lang repo asking if there is any plan to make FileDesc public, and stabilize it ? It seems silly to copy the std private type, it'd make a lot more sense for std to expose it IMO. |
@roblabla Indeed, having this discussion with them would be the smart play before we commit any code to anything. |
This is blocking on the resolution of rust-lang/rust#43254. Right now you can't have both
RawFd
andT: AsRawFd
supported as inputs to the same function, so implementing this doesn't actually improve ergonomics. We may be able to create a newtype wrapper innix
, but I want to see if there might be a solution from the Rust devs here before we do our own newtype-wrapper based implementation.The text was updated successfully, but these errors were encountered: