windows-result
Windows status types, errors, and Result for Win32, COM, and WinRT APIs.
Projected APIs often re-export these types; use this crate directly for low-level error handling.
Get started
[]
= "0.101"
use *;
const ERROR_CANCELLED: WIN32_ERROR = WIN32_ERROR;
Check the API's success convention
| Type | Success |
|---|---|
HRESULT, NTSTATUS |
Any value >= 0 |
BOOL |
Nonzero |
WIN32_ERROR, RPC_STATUS |
Zero |
Use the convention documented for the API, then propagate failures with .ok()?.
HRESULT(1) is success, and not every zero returned by a Win32 function means failure.
For last-error APIs, call BOOL::ok or Error::from_thread immediately after failure.
Another Windows call can overwrite the thread's error.
Error implements core::error::Error; the default std feature adds I/O conversions.