Skip to main content

geokernel_sys/
lib.rs

1//! Raw GeoKernel C ABI. Every call requires the native SDK's pointer, thread,
2//! ownership, callback, and argument preconditions. No native SDK is bundled.
3#![allow(non_snake_case, non_camel_case_types, clippy::too_many_arguments)]
4
5pub use libloading::Error as LoadError;
6use std::{mem::ManuallyDrop, path::Path};
7pub mod types;
8pub use types::*;
9mod generated;
10pub use generated::*;
11
12// Qt owns process-global state that may outlive every wrapper object. Keep
13// loaded modules resident; objects are freed normally, modules at process exit.
14pub(crate) unsafe fn open(path: &Path) -> Result<ManuallyDrop<libloading::Library>, LoadError> {
15    #[cfg(windows)]
16    let library = libloading::os::windows::Library::load_with_flags(
17        path,
18        libloading::os::windows::LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
19            | libloading::os::windows::LOAD_LIBRARY_SEARCH_DEFAULT_DIRS,
20    )?
21    .into();
22    #[cfg(not(windows))]
23    let library = libloading::Library::new(path)?;
24    Ok(ManuallyDrop::new(library))
25}