Sunbeam Studios

Our open-source projects, here for you!

windows-result (0.2.0)

Published 2026-03-26 11:06:15 +00:00 by siennathesane

Installation

[registry]
default = "gitea"

[registries.gitea]
index = "sparse+" # Sparse index
# index = "" # Git

[net]
git-fetch-with-cli = true
cargo add windows-result@0.2.0

About this package

Windows error handling

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(())
}

Dependencies

ID Version
windows-targets ^0.52.6
Details
Cargo
2026-03-26 11:06:15 +00:00
0
Microsoft
MIT OR Apache-2.0
13 KiB
Assets (1)
Versions (2) View all
0.2.0 2026-03-26
0.4.1 2026-03-26