Skip to content

Latest commit

 

History

History
37 lines (28 loc) · 839 Bytes

File metadata and controls

37 lines (28 loc) · 839 Bytes

windows-implement

The windows-implement crate provides the #[implement] macro for implementing COM and WinRT interfaces in Rust.

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

[dependencies]
windows-core = "0.100"
windows-implement = "0.100"
use windows_core::{IUnknown, interface};
use windows_implement::implement;

#[interface("57f61c8b-b400-4035-a7c2-abbddf9e3559")]
unsafe trait IValue: IUnknown {
    fn get(&self) -> u32;
}

#[implement(IValue)]
struct Value(u32);

impl IValue_Impl for Value_Impl {
    unsafe fn get(&self) -> u32 {
        self.0
    }
}

let value: IValue = Value(42).into();
assert_eq!(unsafe { value.get() }, 42);