kataglyphis_rustprojecttemplate/
lib.rs

1#![doc = include_str!("../README.md")]
2#![doc(html_logo_url = "../logo.png")]
3
4#[cxx::bridge]
5mod ffi {
6    extern "Rust" {
7        fn rusty_cxxbridge_integer() -> i32;
8    }
9}
10
11pub mod api;
12pub mod config;
13pub mod detection;
14pub mod logging;
15pub mod platform;
16pub mod resource_monitor;
17pub mod utils;
18
19#[cfg(target_os = "windows")]
20pub(crate) mod gpu_wmi;
21
22#[cfg(feature = "onnxruntime")]
23pub(crate) mod ort_ext;
24
25#[cfg(feature = "burn_demos")]
26pub mod burn_demos;
27
28mod frb_generated;
29#[cfg(onnx)]
30pub(crate) mod person_detection;
31
32#[cfg(all(feature = "gui_unix", not(windows)))]
33pub mod gui;
34#[cfg(feature = "gui_windows")]
35pub mod gui_wgpu;
36
37/// CXX bridge demo stub — returns a fixed integer to verify the Rust-C++ bridge works.
38///
39/// Provide a single, unconditional Rust function so the CXX bridge always finds
40/// `rusty_cxxbridge_integer`. The function picks an implementation based on
41/// cfg flags at compile time.
42pub fn rusty_cxxbridge_integer() -> i32 {
43    if cfg!(all(feature = "with_cxxbridge", not(target_arch = "wasm32"))) {
44        322
45    } else if cfg!(target_arch = "wasm32") {
46        0
47    } else {
48        // fallback: call the C-exported integer function so non-bridge builds
49        // still return a sensible value.
50        rusty_extern_c_integer()
51    }
52}
53
54/// C FFI demo stub — returns a fixed integer to verify `extern "C"` linkage works.
55///
56/// # Safety
57/// Exported with `#[no_mangle]` for C interop. Callers must ensure this is invoked
58/// according to the C calling convention.
59#[unsafe(no_mangle)]
60pub extern "C" fn rusty_extern_c_integer() -> i32 {
61    322
62}