https://github.com/maulingmonkey/winresult
Debug-friendly rust types/codes for windows results
https://github.com/maulingmonkey/winresult
error hresult natvis ntstatus rust wait win32
Last synced: 2 months ago
JSON representation
Debug-friendly rust types/codes for windows results
- Host: GitHub
- URL: https://github.com/maulingmonkey/winresult
- Owner: MaulingMonkey
- License: other
- Created: 2022-02-14T05:37:02.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-06-03T05:19:39.000Z (almost 2 years ago)
- Last Synced: 2025-02-28T12:20:56.367Z (3 months ago)
- Topics: error, hresult, natvis, ntstatus, rust, wait, win32
- Language: Rust
- Homepage:
- Size: 3.08 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# 🦀 winresult - windows result codes 🦀
Debug-friendly types for windows result codes.
[](https://github.com/MaulingMonkey/winresult)
[](https://crates.io/crates/winresult)
[](https://docs.rs/winresult)
[](https://github.com/MaulingMonkey/winresult)### Why?
* `u32` error codes are annoying to `dbg!(...)`. `winresult` has awesome [`Debug`] impls.
* `u32` error codes are annoying to view in your debugger. `winresult` has awesome \*.natvis files. Use [`natvis-pdbs`]!
* typoing `ERROR_WHATEVER` in a `match` is a mere warning. `ERROR::WHATEVER` is a hard error.
(I'd still use `#![deny(unreachable_patterns)]` anyways.)
* `ERROR_INVALID_FUNCTION` == `S_FALSE` (== `1`.) Lame!
* `ERROR_FILE_NOT_FOUND` (2) is a mess. A function or [`GetLastError`] might return:| label | value | notes |
| --------------------------------------------- | ------------- | ----- |
| `ERROR_FILE_NOT_FOUND` | `0x00000002` | Not an [`HRESULT`] (would be "successful") |
| `HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)` | `0x80070002` | [hresult.info](https://www.hresult.info/Search?q=ERROR_FILE_NOT_FOUND) "incorrectly" labels `ERROR_*` as this |
| `NTSTATUS_FROM_WIN32(ERROR_FILE_NOT_FOUND)` | `0xC0070002` | IDK how frequently [`NtStatus`]es get shoved into [`GetLastError`], but I've seen weirder
| `D3D10_ERROR_FILE_NOT_FOUND` | `0x88790002` | Different facility, same code |
| `D3D11_ERROR_FILE_NOT_FOUND` | `0x887C0002` | Different facility, same code |* `ERROR_*` is a mixture of [`HRESULT`]s and non-[`HRESULT`]s. Can you keep them straight? No. No you cannot. Stop lying.
[`Debug`]: https://doc.rust-lang.org/std/fmt/trait.Debug.html
[`GetLastError`]: https://learn.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror
[`HRESULT`]: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/0642cb2f-2075-4469-918c-4441e69c548a
[`natvis-pdbs`]: https://crates.io/crates/natvis-pdbs## License
Licensed under either of
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)at your option.
## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.