com_wrapper/
lib.rs

1extern crate winapi;
2extern crate wio;
3extern crate derive_com_wrapper;
4
5use winapi::Interface;
6use wio::com::ComPtr;
7
8pub use derive_com_wrapper::ComWrapper;
9
10pub trait ComWrapper {
11    /// The raw interface type from `winapi`
12    type Interface: Interface;
13
14    /// Gets a raw pointer to the interface. Does not increment the reference count
15    unsafe fn get_raw(&self) -> *mut Self::Interface;
16
17    /// Consumes the wrapper without affecting the reference count
18    unsafe fn into_raw(self) -> *mut Self::Interface;
19
20    /// Creates a wrapper from the raw pointer. Takes ownership of the pointer for
21    /// reference counting purposes.
22    unsafe fn from_raw(raw: *mut Self::Interface) -> Self;
23
24    /// Creates a wrapper taking ownership of a ComPtr.
25    unsafe fn from_ptr(ptr: ComPtr<Self::Interface>) -> Self;
26
27    /// Unwraps the wrapper into a ComPtr.
28    unsafe fn into_ptr(self) -> ComPtr<Self::Interface>;
29}