Debian Codegraph @

third_party/rust/windows-core/src/imp/generic_factory.rs

raw
1 use crate::Interface;
2 use core::ffi::c_void;
3 use core::mem::{transmute_copy, zeroed};
4
5 // A streamlined version of the IActivationFactory interface used by WinRT class factories used internally by the windows crate
6 // to simplify code generation. Components should implement the `IActivationFactory` interface published by the windows crate.
7 super::define_interface!(
8 IGenericFactory,
9 IGenericFactory_Vtbl,
10 0x00000035_0000_0000_c000_000000000046
11 );
12 super::interface_hierarchy!(IGenericFactory, crate::IUnknown, crate::IInspectable);
13
14 impl IGenericFactory {
15 pub fn ActivateInstance<I: Interface>(&self) -> crate::Result<I> {
16 unsafe {
17 let mut result__ = zeroed();
18 (Interface::vtable(self).ActivateInstance)(
19 transmute_copy(self),
20 &mut result__ as *mut _ as *mut _,
21 )
22 .and_then(|| crate::Type::from_abi(result__))
23 .and_then(|interface: crate::IInspectable| interface.cast())
24 }
25 }
26 }
27
28 #[repr(C)]
29 pub struct IGenericFactory_Vtbl {
30 pub base__: crate::IInspectable_Vtbl,
31 pub ActivateInstance:
32 unsafe extern "system" fn(this: *mut c_void, instance: *mut *mut c_void) -> crate::HRESULT,
33 }