Skip to main content

Crate windows_result

Crate windows_result 

Source
Expand description

§windows-result

The windows-result crate provides Windows error types for Win32, COM, and WinRT APIs.

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

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

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

use windows_result::*;

const S_OK: HRESULT = HRESULT(0);
const ERROR_CANCELLED: WIN32_ERROR = WIN32_ERROR(1223);
const E_CANCELLED: HRESULT = ERROR_CANCELLED.to_hresult();

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 Windows Boolean value.
Error
A Windows error code with optional COM error information.
HRESULT
An error code value returned by most COM functions.
NTSTATUS
An error or status code value returned by some operating system functions.
RPC_STATUS
An error or status code value returned by some operating system functions.
WIN32_ERROR
An error or status code value returned by some operating system functions.

Type Aliases§

Result
A specialized Result type that provides Windows error information.