Attribute Macro windows_implement::implement

source ·
#[implement]
Expand description

Implements one or more COM interfaces.

§Example

Here is a more complete tutorial.

#[interface("094d70d6-5202-44b8-abb8-43860da5aca2")]
unsafe trait IValue: IUnknown {
    fn GetValue(&self, value: *mut i32) -> HRESULT;
}

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

impl IValue_Impl for Value {
    unsafe fn GetValue(&self, value: *mut i32) -> HRESULT {
        *value = self.0;
        HRESULT(0)
    }
}

fn main() {
    let rust_instance = Value(123);
    let com_object: IValue = rust_instance.into();
    // You can now call interface methods on com_object.
}