Skip to content

Type-specific handle validity checking - #1648

Merged
Kenny Kerr (kennykerr) merged 6 commits into
masterfrom
handles
Mar 31, 2022
Merged

Kenny Kerr (kennykerr) merged 6 commits into
masterfrom
handles

Conversation

@kennykerr

@kennykerr Kenny Kerr (kennykerr) commented Mar 31, 2022 •

Copy link
Copy Markdown
Collaborator

The win32 metadata now includes information about what constitutes invalid handle values. This update plumbs this through so that you can accurately check whether a handle returned by some function is invalid. Handles will have an is_invalid method if their underlying type is a pointer or have at least one invalid value.

With this information in hand, the bindgen crate can now combine this with metadata that indicates whether a particular function set the last error so that the caller should use GetLastError on failure. This means that functions that return a handle and provide error information in this way will now be transformed to return -> Result<HANDLE> instead of just -> HANDLE. This should make error handling more predictable.

Fixes #1630

Comment thread crates/libs/bindgen/src/handles.rs Resolved
Comment thread crates/libs/bindgen/src/handles.rs Resolved
Comment thread crates/libs/bindgen/src/functions.rs Resolved
Comment thread crates/libs/bindgen/src/handles.rs Resolved

@riverar Rafael Rivera (riverar) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice! Really cool to see all this light up with a sprinkle of metadata 🎉

@kennykerr
Kenny Kerr (kennykerr) merged commit ab6994f into master Mar 31, 2022
@kennykerr
Kenny Kerr (kennykerr) deleted the handles branch March 31, 2022 20:08
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.

Bug: FindVolumeHandle::is_invalid() does not check for a value of -1

2 participants