1pub mod api;
4pub mod d2d1;
5pub mod d3d;
6#[cfg(feature = "d3d11")]
7pub mod d3d11;
8#[cfg(all(feature = "d3d11on12", feature = "d3d11", feature = "d3d12"))]
9pub mod d3d11on12;
10#[cfg(feature = "d3d11sdklayers")]
11mod d3d11sdklayers;
12#[cfg(feature = "d3d12")]
13pub mod d3d12;
14#[cfg(feature = "d3d12sdklayers")]
15mod d3d12sdklayers;
16#[cfg(feature = "d3dcompiler")]
17pub mod d3dcompiler;
18#[cfg(feature = "dwrite")]
19pub mod dwrite;
20pub mod dxgi;
21pub mod result;
22mod utility;
23
24#[doc(inline)]
25pub use api::{EventHandle, Guid, Luid, Point, Rect, WindowHandle};
26#[doc(inline)]
27pub use result::HResult;
28
29use winapi::um::unknwnbase::IUnknown;
30
31pub trait Interface {
33 type APIType: winapi::Interface;
34 fn new(p: com_ptr::ComPtr<Self::APIType>) -> Self;
35 fn uuidof() -> api::Guid;
36 fn as_ptr(&self) -> *mut Self::APIType;
37 fn as_com_ptr(&self) -> &com_ptr::ComPtr<Self::APIType>;
38 fn as_unknown(&self) -> *mut IUnknown;
39 fn from_com_ptr(p: com_ptr::ComPtr<Self::APIType>) -> Self;
40 fn query_interface<T: Interface>(&self) -> Result<T, result::HResult>;
41}
42
43#[derive(Clone, Debug)]
44pub struct Unknown(com_ptr::ComPtr<IUnknown>);
45impl_interface!(Unknown, IUnknown);
46
47impl Unknown {
48 pub fn from_interface(interface: &impl Interface) -> Unknown {
49 Unknown(
50 interface
51 .as_com_ptr()
52 .query_interface::<IUnknown>()
53 .unwrap(),
54 )
55 }
56}