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

Feature request: use primitives from standard library #1745

Closed
jonathan-a-thomason opened this issue May 9, 2022 · 4 comments
Closed

Feature request: use primitives from standard library #1745

jonathan-a-thomason opened this issue May 9, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@jonathan-a-thomason
Copy link

jonathan-a-thomason commented May 9, 2022

Motivation

I believe it would be more consistent with rust to make use of the resources in std::os::windows. This includes std::os::windows::raw::HANDLE and std::os::windows::raw::SOCKET.
This would make use of the standard library with windows-rs crate easier by making use of compatibility between them.

Drawbacks

None that I can see yet.

Alternatives

A possible alternative is to take the current HANDLE in windows-rs and apply a trait to it such as std::os::windows::io::AsRawHandle to convert back to the standard library types.

Additional context

This is related to #760.

@jonathan-a-thomason jonathan-a-thomason added the enhancement New feature or request label May 9, 2022
@kennykerr
Copy link
Collaborator

The challenge with the first approach is that Windows has many handle types whereas the standard library only defines HANDLE and SOCKET and even those it defines in a somewhat questionable way (handles aren't necessarily pointers and sockets are pointer-sized integers). I would however be open to exploring implementing the second alternative of implementing the standard library trait. Also related to #1622.

@riverar
Copy link
Collaborator

riverar commented May 9, 2022

Right, std::os::windows::raw::HANDLE doesn't appear to be valid. There's a handle discussion here you might find fun to read #1643. There is also rust-lang/rust#95490.

@ryancerium
Copy link
Contributor

The pointer provenance stuff was the first thing that crossed my mind as well @riverar .

@kennykerr
Copy link
Collaborator

Thanks for the reminder. Closing in favor of those other conversations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants