Skip to main content

ComObjectInner

Trait ComObjectInner 

pub trait ComObjectInner: Sized + 'static {
    type Outer: IUnknownImpl<Impl = Self>;

    // Required method
    fn into_object(self) -> ComObject<Self>;
}
Expand description

Identifies types that can be placed in ComObject.

This is an implementation detail of the Windows crates. The #[implement] macro generates implementations so user code can use ComObject<T> instead of ComObject<T_Impl>. Implementation state must be 'static, since even borrowed interface views can be cloned into owned interfaces that outlive their creator.

ⓘ
use windows_core::*;
#[interface("094d70d6-5202-44b8-abb8-43860da5aca2")]
unsafe trait IFoo: IUnknown {}
#[implement(IFoo)]
struct Foo;
impl IFoo_Impl for Foo_Impl {}
let outer = Foo.into_outer();
let interface: IFoo = outer.to_interface();

Required Associated Types§

type Outer: IUnknownImpl<Impl = Self>

The generated <foo>_Impl type (aka the “boxed” or “outer” type).

Required Methods§

fn into_object(self) -> ComObject<Self>

Moves an instance of this type into a new ComObject box and returns it.

§Safety

Safe Rust code must not own a generated “outer” COM object type (e.g. <foo>_Impl), because it carries a reference count and methods that can destroy the object. The #[implement] macro constructs that value, places it on the heap, and returns only a ComObject reference.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§