-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Tracking Issue for std::os::fd #98699
Comments
Is "OS's that use fds" anything other than just "Unix and Wasi"? How close is Wasi to Unix? Would we treat Wasi similar to Unix in other situations too? |
std::os::solid and std::os::fortanix_sgx also have similar types and traits. I'm not familiar with those platforms, but they also may want to use std::os::fd.
That's a complex question :-}. As a platform, WASI lacks some fundamental Unixy things, like |
Has there been any discussion on |
I'm not aware of any. One way to do this today, if you're on Unix and know you're doing |
I have an |
I can see the utility, but there is also the question of the overall API shape. Not all file descriptors support There has also been some discussion about possible "view" types; I have a crate which lets you do |
I think Since it's so commonly available, I propose just making it available everywhere and the rare OSes that don't support file descriptors in some fashion can just ignore it. this also provides the benefit of having a sneaky way to get a non-negative-one integer type: |
On Windows, there are several different plausible choices to be the file descriptor type: C runtime library file descriptors, Foundation Please don't use |
i would assume file descriptors always mean c runtime library file descriptors, since i've never seen handles or sockets referred to as file descriptors. |
we could define FDs to be the type used for C's |
Could you describe what use case(s) would motivate this? I myself don't know of any use cases that want to use the C runtime library APIs on Windows. |
when C libraries use posix file descriptors and you want to use those libraries from rust |
My feedback here is that if you're serious about wanting this, the more detail you can provide about use cases that would benefit from it, the easier it would be to consider. One thing to keep in mind is that if |
what I wanted to do was obtain a non-neg-one-int that would work on all platforms, the other reasons for wanting FDs are because I know it'll be useful on all POSIX OSes (including Windows), not because I have any plans to use it myself. |
that's not entirely true, file descriptors can be converted to handles and back: |
I stumbled upon the portability issue above today. I wrote |
std::os::fd was stabilized in 1.66.0. Is there something else missing or should this be closed? |
Yes, |
Feature gate:
#![feature(os_fd)]
This is a tracking issue for the
std::os::fd
module, which is currently defined onboth Unix and WASI , and contains
OwnedFd
,BorrowedFd
,RawFd
,AsFd
,AsRawFd
,IntoRawFd
, andFromRawFd
.Public API
The types and traits are the same as those already defined in
std::os::unix::io
and
std::os::wasi::io
. This PR is just introducing a new alias for them to helpusers write portable code.
Steps / History
std::os::fd
public. #98368Unresolved Questions
std::os
. One can think of it as meaning "OS's that use fds". Is that weird?The text was updated successfully, but these errors were encountered: