Crate windows_result

Source
Expand description

§Windows error handling

The windows-result crate provides efficient Windows error handling and propagation with support for Win32, COM, and WinRT APIs.

Start by adding the following to your Cargo.toml file:

[dependencies.windows-result]
version = "0.3"

Use the HRESULT, Error, and specialized Result types as needed:

use windows_result::*;

const S_OK: HRESULT = HRESULT(0);
const ERROR_CANCELLED: u32 = 1223;
const E_CANCELLED: HRESULT = HRESULT::from_win32(ERROR_CANCELLED);

fn main() -> Result<()> {
    S_OK.ok()?;
    let e = Error::new(E_CANCELLED, "test message");
    assert_eq!(e.code(), E_CANCELLED);
    assert_eq!(e.message(), "test message");
    Ok(())
}

Structs§

BOOL
A 32-bit value representing boolean values and returned by some functions to indicate success or failure.
Error
An error object consists of both an error code and optional detailed error information for debugging.
HRESULT
An error code value returned by most COM functions.

Type Aliases§

Result
A specialized Result type that provides Windows error information.