use std::ffi::{CString, c_char}; use thiserror::Error as TeError; mod object_pool; mod last_error; mod cstr_ffi; mod wrapper; // region: Error /// Error occurs in this crate. #[derive(Debug, TeError)] enum Error { /// Error when operating Schema. #[error("{0}")] Schema(#[from] wfassoc::highlevel::SchemaError), /// Error when parsing Schema into Program. #[error("{0}")] ParseProgram(#[from] wfassoc::highlevel::ParseProgramError), /// Error when operating Program. #[error("{0}")] Program(#[from] wfassoc::highlevel::ProgramError), /// Error when manipulating with C-style string. #[error("{0}")] CStrFfi(#[from] cstr_ffi::Error), } /// Result type used in this crate. type Result = std::result::Result; // endregion // region: Macros // endregion #[unsafe(no_mangle)] pub extern "C" fn WFStartup() -> bool { true } #[unsafe(no_mangle)] pub extern "C" fn WFShutdown() -> bool { true } #[unsafe(no_mangle)] pub extern "C" fn WFGetLastError() -> *const c_char { last_error::get_last_error() } #[unsafe(no_mangle)] pub extern "C" fn WFHasPrivilege() -> bool { wfassoc::win32::utilities::has_privilege() } #[unsafe(no_mangle)] pub extern "C" fn WFAdd(left: u32, right: u32, rv: *mut u32) -> bool { unsafe { *rv = left + right; } return true; }