use once_cell::unsync::OnceCell;
use libloading::Library;
use super::call_ffi;
static mut DYLIB: OnceCell<Library> = OnceCell::new();
pub fn load_dylib(path: &str) {
unsafe { DYLIB.set(Library::new(path).unwrap()).unwrap() }
}
pub fn is_loaded() -> bool {
unsafe { DYLIB.get().is_some() }
}
pub fn first_pkt_len() -> u32 {
call_ffi!(DYLIB, b"realm_first_pkt_len" => unsafe extern "C" fn() -> u32)
}
pub fn decide_remote_idx(idx: i32, buf: *const u8) -> i32 {
call_ffi!(
DYLIB, b"realm_decide_remote_idx" => unsafe extern "C" fn(i32, *const u8) -> i32,
idx, buf
)
}