2026-05-10 16:43:25 +08:00
|
|
|
|
2025-10-18 18:17:05 +08:00
|
|
|
use std::ffi::{CString, c_char};
|
|
|
|
|
use thiserror::Error as TeError;
|
|
|
|
|
|
2026-05-09 16:27:04 +08:00
|
|
|
mod object_pool;
|
2025-11-26 22:40:17 +08:00
|
|
|
mod last_error;
|
2026-05-10 16:43:25 +08:00
|
|
|
mod cstr_ffi;
|
2026-01-04 14:05:34 +08:00
|
|
|
mod wrapper;
|
2025-11-26 22:40:17 +08:00
|
|
|
|
2025-10-18 18:17:05 +08:00
|
|
|
// region: Error
|
|
|
|
|
|
|
|
|
|
/// Error occurs in this crate.
|
|
|
|
|
#[derive(Debug, TeError)]
|
|
|
|
|
enum Error {
|
2026-05-10 16:55:09 +08:00
|
|
|
/// Error when operating Schema.
|
|
|
|
|
#[error("{0}")]
|
|
|
|
|
Schema(#[from] wfassoc::highlevel::SchemaError),
|
2026-05-09 16:27:04 +08:00
|
|
|
/// Error when parsing Schema into Program.
|
2025-10-18 18:17:05 +08:00
|
|
|
#[error("{0}")]
|
2026-05-09 16:27:04 +08:00
|
|
|
ParseProgram(#[from] wfassoc::highlevel::ParseProgramError),
|
|
|
|
|
/// Error when operating Program.
|
|
|
|
|
#[error("{0}")]
|
|
|
|
|
Program(#[from] wfassoc::highlevel::ProgramError),
|
2025-10-18 18:17:05 +08:00
|
|
|
|
2026-05-10 16:55:09 +08:00
|
|
|
/// Error when manipulating with C-style string.
|
|
|
|
|
#[error("{0}")]
|
|
|
|
|
CStrFfi(#[from] cstr_ffi::Error),
|
2025-10-18 18:17:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Result type used in this crate.
|
|
|
|
|
type Result<T> = std::result::Result<T, Error>;
|
|
|
|
|
|
|
|
|
|
// endregion
|
|
|
|
|
|
|
|
|
|
// region: Macros
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// endregion
|
2025-10-04 22:04:30 +08:00
|
|
|
|
2025-10-18 09:55:08 +08:00
|
|
|
#[unsafe(no_mangle)]
|
2025-10-18 23:11:33 +08:00
|
|
|
pub extern "C" fn WFStartup() -> bool {
|
2026-05-10 16:55:09 +08:00
|
|
|
true
|
2025-10-18 23:11:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[unsafe(no_mangle)]
|
|
|
|
|
pub extern "C" fn WFShutdown() -> bool {
|
2026-05-10 16:55:09 +08:00
|
|
|
true
|
2025-10-18 23:11:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[unsafe(no_mangle)]
|
|
|
|
|
pub extern "C" fn WFGetLastError() -> *const c_char {
|
2025-11-26 22:40:17 +08:00
|
|
|
last_error::get_last_error()
|
2025-10-18 23:11:33 +08:00
|
|
|
}
|
|
|
|
|
|
2025-10-19 14:10:21 +08:00
|
|
|
#[unsafe(no_mangle)]
|
|
|
|
|
pub extern "C" fn WFHasPrivilege() -> bool {
|
2026-05-09 16:27:04 +08:00
|
|
|
wfassoc::win32::utilities::has_privilege()
|
2025-10-19 14:10:21 +08:00
|
|
|
}
|
|
|
|
|
|
2025-10-18 23:11:33 +08:00
|
|
|
#[unsafe(no_mangle)]
|
|
|
|
|
pub extern "C" fn WFAdd(left: u32, right: u32, rv: *mut u32) -> bool {
|
|
|
|
|
unsafe { *rv = left + right; }
|
|
|
|
|
return true;
|
2025-10-04 22:04:30 +08:00
|
|
|
}
|