1use crate::co;
2use crate::decl::*;
3use crate::kernel::privs::*;
4
5pub enum AddrStr {
9 None,
11 Addr(*mut std::ffi::c_void),
13 Str(WString),
15}
16
17impl AddrStr {
18 #[must_use]
20 pub fn from_str(v: &str) -> Self {
21 Self::Str(WString::from_str(v))
22 }
23}
24
25pub enum ClaimSecurityAttr<'a> {
29 Int64(&'a [i64]),
30 Uint64(&'a [u64]),
31 String(Vec<String>),
32 Fbqn(&'a [CLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE<'a>]),
33 OctetString(&'a [CLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE<'a>]),
34}
35
36#[derive(Clone)]
52pub enum IdStr {
53 Id(u16),
55 Str(WString),
57}
58
59impl std::fmt::Display for IdStr {
60 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
61 match self {
62 Self::Id(rt) => write!(f, "ID: {}", rt),
63 Self::Str(str) => write!(f, "Str: {}", str),
64 }
65 }
66}
67
68impl IdStr {
69 #[must_use]
71 pub fn from_str(v: &str) -> Self {
72 Self::Str(WString::from_str(v))
73 }
74
75 #[must_use]
82 pub unsafe fn from_ptr(ptr: *const u16) -> IdStr {
83 if IS_INTRESOURCE(ptr) {
84 Self::Id(ptr as _)
85 } else {
86 Self::Str(unsafe { WString::from_wchars_nullt(ptr) })
87 }
88 }
89
90 #[must_use]
92 pub fn as_ptr(&self) -> *const u16 {
93 match self {
94 Self::Id(id) => MAKEINTRESOURCE(*id as _),
95 Self::Str(ws) => ws.as_ptr(),
96 }
97 }
98}
99
100pub enum PowerSetting {
104 AcDcPowerSource(co::SYSTEM_POWER_CONDITION),
105 BatteryPercentageRemaining(u8),
106 ConsoleDisplayState(co::MONITOR_DISPLAY_STATE),
107 GlobalUserPresence(co::USER_ACTIVITY_PRESENCE),
108 IdleBackgroundTask,
109 MonitorPowerOn(bool),
110 PowerSavingStatus(bool),
111 PowerSchemePersonality(co::POWER_SAVINGS),
112 SessionDisplayStatus(co::MONITOR_DISPLAY_STATE),
113 SessionUserPresence(co::USER_ACTIVITY_PRESENCE),
114 LidSwitchStateChange(PowerSettingLid),
115 SystemAwayMode(PowerSettingAwayMode),
116}
117
118#[derive(Clone, Copy, PartialEq, Eq)]
122pub enum PowerSettingAwayMode {
123 Exiting,
124 Entering,
125}
126
127#[derive(Clone, Copy, PartialEq, Eq)]
131pub enum PowerSettingLid {
132 Closed,
133 Opened,
134}
135
136#[derive(Clone)]
147pub enum RtStr {
148 Rt(co::RT),
150 Str(WString),
152}
153
154impl std::fmt::Display for RtStr {
155 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
156 match self {
157 Self::Rt(rt) => write!(f, "RT: {}", rt),
158 Self::Str(str) => write!(f, "Str: {}", str),
159 }
160 }
161}
162
163impl RtStr {
164 #[must_use]
166 pub fn from_str(v: &str) -> Self {
167 Self::Str(WString::from_str(v))
168 }
169
170 #[must_use]
177 pub unsafe fn from_ptr(ptr: *const u16) -> RtStr {
178 if IS_INTRESOURCE(ptr) {
179 Self::Rt(unsafe { co::RT::from_raw(ptr as _) })
180 } else {
181 Self::Str(unsafe { WString::from_wchars_nullt(ptr) })
182 }
183 }
184
185 #[must_use]
187 pub fn as_ptr(&self) -> *const u16 {
188 match self {
189 Self::Rt(id) => MAKEINTRESOURCE(id.raw() as _),
190 Self::Str(ws) => ws.as_ptr(),
191 }
192 }
193}