windows-result

Crates.iowindows-result
lib.rswindows-result
version0.2.0
sourcesrc
created_at2024-02-02 16:47:12.691453
updated_at2024-07-03 19:46:24.64578
descriptionWindows error handling
homepage
repositoryhttps://github.com/microsoft/windows-rs
max_upload_size
id1124556
size40,565
Kenny Kerr (kennykerr)

documentation

README

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.2"

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(())
}
Commit count: 1510

cargo fmt