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::*;
11pub mod globe;
12pub use globe::GlobeApi;
13
14// Qt owns process-global state that may outlive every wrapper object. Keep
15// loaded modules resident; objects are freed normally, modules at process exit.
16pub(crate) unsafe fn open(path: &Path) -> Result<ManuallyDrop<libloading::Library>, LoadError> {
17    #[cfg(windows)]
18    let library = libloading::os::windows::Library::load_with_flags(
19        path,
20        libloading::os::windows::LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
21            | libloading::os::windows::LOAD_LIBRARY_SEARCH_DEFAULT_DIRS,
22    )?
23    .into();
24    #[cfg(not(windows))]
25    let library = libloading::Library::new(path)?;
26    Ok(ManuallyDrop::new(library))
27}