1use crate::{common, sys, MaaResult};
4use std::ffi::{CStr, CString};
5
6pub fn version() -> String {
7 unsafe {
8 let ptr = sys::MaaVersion();
9 if ptr.is_null() {
10 String::new()
11 } else {
12 CStr::from_ptr(ptr).to_string_lossy().into_owned()
13 }
14 }
15}
16
17pub fn load_plugin(path: &str) -> MaaResult<()> {
18 let c_path = CString::new(path)?;
19 let ret = unsafe { sys::MaaGlobalLoadPlugin(c_path.as_ptr()) };
20 common::check_bool(ret)
21}
22
23pub mod logging {
24 use super::*;
25
26 pub fn set_log_dir(path: &str) -> MaaResult<()> {
27 let c_path = CString::new(path)?;
28 let len = c_path.as_bytes().len();
29 unsafe {
30 let ret = sys::MaaGlobalSetOption(
31 sys::MaaGlobalOptionEnum_MaaGlobalOption_LogDir as i32,
32 c_path.as_ptr() as *mut _,
33 len as u64,
34 );
35 common::check_bool(ret)
36 }
37 }
38}