eric_bindings/
lib.rs

1#![allow(non_upper_case_globals)]
2#![allow(non_camel_case_types)]
3#![allow(non_snake_case)]
4#![allow(dead_code)]
5// TODO: extern block uses type u128, which is not FFI-safe
6#![allow(improper_ctypes)]
7
8include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
9
10#[cfg(test)]
11mod tests {
12    use super::*;
13    use anyhow::Context;
14    use std::{env, ffi::CString};
15
16    #[test]
17    fn test_ericapi() {
18        let plugin_path =
19            env::var("PLUGIN_PATH").expect("Missing environment variable 'PLUGIN_PATH'");
20        let plugin_path = CString::new(plugin_path)
21            .context("Can't convert to CString")
22            .unwrap();
23
24        let log_path =
25            env::current_dir().expect("Missing environment variable for current directory");
26        let log_path = CString::new(log_path.to_str().unwrap())
27            .context("Can't convert to CString")
28            .unwrap();
29
30        unsafe {
31            let error_code = EricInitialisiere(plugin_path.as_ptr(), log_path.as_ptr());
32            assert_eq!(error_code, 0);
33
34            let buffer = EricRueckgabepufferErzeugen();
35            let error_code = EricVersion(buffer);
36            assert_eq!(error_code, 0);
37
38            let error_code = EricBeende();
39            assert_eq!(error_code, 0);
40        }
41    }
42}