2026-08-15 09:50:15 +08:00
|
|
|
//! The module including all wrapper types for FFI.
|
2026-05-18 13:33:57 +08:00
|
|
|
|
2026-08-15 09:50:15 +08:00
|
|
|
use std::ffi::c_void;
|
2026-05-18 13:33:57 +08:00
|
|
|
use num_enum::TryFromPrimitive;
|
|
|
|
|
|
|
|
|
|
// region: HICON
|
|
|
|
|
|
|
|
|
|
/// The type representing Win32 HICON handle.
|
|
|
|
|
///
|
|
|
|
|
/// In theory, we can fetch HICON type from "windows_sys" crate.
|
|
|
|
|
/// However, I don't want to add it as this crate's dependency,
|
|
|
|
|
/// because I don't use anything within it except this type.
|
|
|
|
|
/// So I check Microsoft document, re-define it in there for this crate.
|
2026-06-26 13:44:56 +08:00
|
|
|
/// Reference: <https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types>
|
2026-05-18 13:33:57 +08:00
|
|
|
pub type HICON = *mut c_void;
|
|
|
|
|
|
|
|
|
|
/// The invalid value of Win32 HICON handle.
|
|
|
|
|
///
|
2026-06-17 21:40:19 +08:00
|
|
|
/// The same reason like [WFHICON] to re-define it in there.
|
2026-05-19 10:59:57 +08:00
|
|
|
pub const INVALID_HICON: HICON = std::ptr::null_mut();
|
2026-05-18 13:33:57 +08:00
|
|
|
|
|
|
|
|
// endregion
|
|
|
|
|
|
|
|
|
|
// region: Scope
|
|
|
|
|
|
|
|
|
|
/// The FFI wrapper for [wfassoc::Scope].
|
|
|
|
|
#[repr(u32)]
|
|
|
|
|
#[derive(Debug, Copy, Clone, TryFromPrimitive)]
|
|
|
|
|
pub enum Scope {
|
|
|
|
|
User = 0,
|
|
|
|
|
System = 1,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl From<Scope> for wfassoc::Scope {
|
|
|
|
|
fn from(value: Scope) -> Self {
|
|
|
|
|
match value {
|
|
|
|
|
Scope::User => wfassoc::Scope::User,
|
|
|
|
|
Scope::System => wfassoc::Scope::System,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// endregion
|
|
|
|
|
|
|
|
|
|
// region: View
|
|
|
|
|
|
|
|
|
|
/// The FFI wrapper for [wfassoc::View].
|
|
|
|
|
#[repr(u32)]
|
|
|
|
|
#[derive(Debug, Copy, Clone, TryFromPrimitive)]
|
|
|
|
|
pub enum View {
|
|
|
|
|
User = 0,
|
|
|
|
|
System = 1,
|
|
|
|
|
Hybrid = 2,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl From<View> for wfassoc::View {
|
|
|
|
|
fn from(value: View) -> Self {
|
|
|
|
|
match value {
|
|
|
|
|
View::User => wfassoc::View::User,
|
|
|
|
|
View::System => wfassoc::View::System,
|
|
|
|
|
View::Hybrid => wfassoc::View::Hybrid,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// endregion
|
2026-08-15 09:50:15 +08:00
|
|
|
|
|
|
|
|
// region: Misc Types and Constants
|
|
|
|
|
|
|
|
|
|
/// The invalid value of index.
|
|
|
|
|
pub const INVALID_INDEX: usize = usize::MAX;
|
|
|
|
|
|
|
|
|
|
// endregion
|