1#![rustfmt::skip]
2
3#[repr(transparent)]
4#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5pub struct HANDLE(pub *mut core::ffi::c_void);
6impl HANDLE {
7 pub fn is_invalid(&self) -> bool {
8 self.0 == -1 as _ || self.0 == 0 as _
9 }
10}
11impl Default for HANDLE {
23 fn default() -> Self {
24 unsafe { core::mem::zeroed() }
25 }
26}
27
28#[repr(transparent)]
29#[derive(Clone, Copy, Debug, PartialEq, Eq)]
30pub struct HMODULE(pub *mut core::ffi::c_void);
31impl HMODULE {
32 pub fn is_invalid(&self) -> bool {
33 self.0.is_null()
34 }
35}
36impl Default for HMODULE {
48 fn default() -> Self {
49 unsafe { core::mem::zeroed() }
50 }
51}
52#[repr(C)]
60#[derive(Clone, Copy, Debug, PartialEq)]
61pub struct LUID {
62 pub LowPart: u32,
63 pub HighPart: i32,
64}
65impl Default for LUID {
66 fn default() -> Self {
67 unsafe { core::mem::zeroed() }
68 }
69}
70
71#[must_use]
72#[repr(transparent)]
73#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
74pub struct BOOL(pub i32);
75
76impl BOOL {
77 #[inline]
78 pub fn as_bool(self) -> bool {
79 self.0 != 0
80 }
81 #[inline]
82 pub fn ok(self) -> windows_core::Result<()> {
83 if self.as_bool() {
84 Ok(())
85 } else {
86 Err(windows_core::Error::from_win32())
87 }
88 }
89 #[inline]
90 #[track_caller]
91 pub fn unwrap(self) {
92 self.ok().unwrap();
93 }
94 #[inline]
95 #[track_caller]
96 pub fn expect(self, msg: &str) {
97 self.ok().expect(msg);
98 }
99}
100impl From<BOOL> for bool {
101 fn from(value: BOOL) -> Self {
102 value.as_bool()
103 }
104}
105impl From<&BOOL> for bool {
106 fn from(value: &BOOL) -> Self {
107 value.as_bool()
108 }
109}
110impl From<bool> for BOOL {
111 fn from(value: bool) -> Self {
112 if value {
113 Self(1)
114 } else {
115 Self(0)
116 }
117 }
118}
119impl From<&bool> for BOOL {
120 fn from(value: &bool) -> Self {
121 (*value).into()
122 }
123}
124impl PartialEq<bool> for BOOL {
125 fn eq(&self, other: &bool) -> bool {
126 self.as_bool() == *other
127 }
128}
129
130#[repr(C)]
131#[derive(Clone, Copy, Debug, PartialEq)]
132pub struct RECT {
133 pub left: i32,
134 pub top: i32,
135 pub right: i32,
136 pub bottom: i32,
137}
138impl Default for RECT {
139 fn default() -> Self {
140 unsafe { core::mem::zeroed() }
141 }
142}
143
144#[repr(C)]
145#[derive(Clone, Copy, Debug, PartialEq)]
146pub struct SIZE {
147 pub cx: i32,
148 pub cy: i32,
149}
150impl Default for SIZE {
151 fn default() -> Self {
152 unsafe { core::mem::zeroed() }
153 }
154}
155
156#[repr(C)]
157#[derive(Clone, Copy, Debug, PartialEq)]
158pub struct POINT {
159 pub x: i32,
160 pub y: i32,
161}
162impl Default for POINT {
163 fn default() -> Self {
164 unsafe { core::mem::zeroed() }
165 }
166}
167
168#[repr(transparent)]
169#[derive(Clone, Copy, Debug, PartialEq, Eq)]
170pub struct HWND(pub *mut core::ffi::c_void);
171impl HWND {
172 pub fn is_invalid(&self) -> bool {
173 self.0.is_null()
174 }
175}
176impl Default for HWND {
177 fn default() -> Self {
178 unsafe { core::mem::zeroed() }
179 }
180}
181impl windows_core::imp::CanInto<HANDLE> for HWND {}
182impl From<HWND> for HANDLE {
183 fn from(value: HWND) -> Self {
184 Self(value.0)
185 }
186}
187pub const S_FALSE: windows_core::HRESULT = windows_core::HRESULT(0x1_u32 as _);
188pub const S_OK: windows_core::HRESULT = windows_core::HRESULT(0x0_u32 as _);
189pub const E_INVALIDARG: windows_core::HRESULT = windows_core::HRESULT(0x80070057_u32 as _);
190pub const E_FAIL: windows_core::HRESULT = windows_core::HRESULT(0x80004005_u32 as _);
191pub const DXGI_DDI_ERR_NONEXCLUSIVE: windows_core::HRESULT = windows_core::HRESULT(0x887B0003_u32 as _);
192pub const DXGI_DDI_ERR_UNSUPPORTED: windows_core::HRESULT = windows_core::HRESULT(0x887B0002_u32 as _);
193pub const DXGI_DDI_ERR_WASSTILLDRAWING: windows_core::HRESULT = windows_core::HRESULT(0x887B0001_u32 as _);
194pub const DXGI_STATUS_CLIPPED: windows_core::HRESULT = windows_core::HRESULT(0x87A0002_u32 as _);
195pub const DXGI_STATUS_DDA_WAS_STILL_DRAWING: windows_core::HRESULT = windows_core::HRESULT(0x87A000A_u32 as _);
196pub const DXGI_STATUS_GRAPHICS_VIDPN_SOURCE_IN_USE: windows_core::HRESULT = windows_core::HRESULT(0x87A0006_u32 as _);
197pub const DXGI_STATUS_MODE_CHANGED: windows_core::HRESULT = windows_core::HRESULT(0x87A0007_u32 as _);
198pub const DXGI_STATUS_MODE_CHANGE_IN_PROGRESS: windows_core::HRESULT = windows_core::HRESULT(0x87A0008_u32 as _);
199pub const DXGI_STATUS_NO_DESKTOP_ACCESS: windows_core::HRESULT = windows_core::HRESULT(0x87A0005_u32 as _);
200pub const DXGI_STATUS_NO_REDIRECTION: windows_core::HRESULT = windows_core::HRESULT(0x87A0004_u32 as _);
201pub const DXGI_STATUS_OCCLUDED: windows_core::HRESULT = windows_core::HRESULT(0x87A0001_u32 as _);
202pub const DXGI_STATUS_PRESENT_REQUIRED: windows_core::HRESULT = windows_core::HRESULT(0x87A002F_u32 as _);
203pub const DXGI_STATUS_UNOCCLUDED: windows_core::HRESULT = windows_core::HRESULT(0x87A0009_u32 as _);