use crate::co;
use crate::decl::*;
use crate::kernel::privs::*;
pub enum AddrStr {
None,
Addr(*mut std::ffi::c_void),
Str(WString),
}
impl AddrStr {
#[must_use]
pub fn from_str(v: &str) -> Self {
Self::Str(WString::from_str(v))
}
}
pub enum ClaimSecurityAttr<'a> {
Int64(&'a [i64]),
Uint64(&'a [u64]),
String(Vec<String>),
Fbqn(&'a [CLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE<'a>]),
OctetString(&'a [CLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE<'a>]),
}
#[derive(Clone)]
pub enum IdStr {
Id(u16),
Str(WString),
}
impl std::fmt::Display for IdStr {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
use IdStr::*;
match self {
Id(rt) => write!(f, "ID: {}", rt),
Str(str) => write!(f, "Str: {}", str),
}
}
}
impl IdStr {
#[must_use]
pub fn from_str(v: &str) -> Self {
Self::Str(WString::from_str(v))
}
#[must_use]
pub unsafe fn from_ptr(ptr: *const u16) -> IdStr {
if IS_INTRESOURCE(ptr) {
Self::Id(ptr as _)
} else {
Self::Str(unsafe { WString::from_wchars_nullt(ptr) })
}
}
#[must_use]
pub fn as_ptr(&self) -> *const u16 {
use IdStr::*;
match self {
Id(id) => MAKEINTRESOURCE(*id as _),
Str(ws) => ws.as_ptr(),
}
}
}
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum PidParent {
Pid(u32),
Parent,
}
impl PidParent {
#[must_use]
pub const fn as_u32(&self) -> u32 {
use PidParent::*;
match self {
Pid(pid) => *pid,
Parent => ATTACH_PARENT_PROCESS,
}
}
}
pub enum PowerSetting {
AcDcPowerSource(co::SYSTEM_POWER_CONDITION),
BatteryPercentageRemaining(u8),
ConsoleDisplayState(co::MONITOR_DISPLAY_STATE),
GlobalUserPresence(co::USER_ACTIVITY_PRESENCE),
IdleBackgroundTask,
MonitorPowerOn(bool),
PowerSavingStatus(bool),
PowerSchemePersonality(co::POWER_SAVINGS),
SessionDisplayStatus(co::MONITOR_DISPLAY_STATE),
SessionUserPresence(co::USER_ACTIVITY_PRESENCE),
LidSwitchStateChange(PowerSettingLid),
SystemAwayMode(PowerSettingAwayMode),
}
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum PowerSettingAwayMode {
Exiting,
Entering,
}
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum PowerSettingLid {
Closed,
Opened,
}
#[derive(Clone)]
pub enum RtStr {
Rt(co::RT),
Str(WString),
}
impl std::fmt::Display for RtStr {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
use RtStr::*;
match self {
Rt(rt) => write!(f, "RT: {}", rt),
Str(str) => write!(f, "Str: {}", str),
}
}
}
impl RtStr {
#[must_use]
pub fn from_str(v: &str) -> Self {
Self::Str(WString::from_str(v))
}
#[must_use]
pub unsafe fn from_ptr(ptr: *const u16) -> RtStr {
if IS_INTRESOURCE(ptr) {
Self::Rt(unsafe { co::RT::from_raw(ptr as _) })
} else {
Self::Str(unsafe { WString::from_wchars_nullt(ptr) })
}
}
#[must_use]
pub fn as_ptr(&self) -> *const u16 {
use RtStr::*;
match self {
Rt(id) => MAKEINTRESOURCE(id.raw() as _),
Str(ws) => ws.as_ptr(),
}
}
}