1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Ignore style warnings for for byondapi-c bindings
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(clippy::missing_safety_doc)]

use std::path::Path;

#[cfg(not(target_pointer_width = "32"))]
compile_error!("BYOND API only functions with 32-bit targets");

#[cfg(not(target_arch = "x86"))]
compile_error!("BYOND API only functions on x86 targets");

#[cfg(not(any(target_os = "linux", target_os = "windows")))]
compile_error!("BYOND API only supports Windows and Linux");

// Include byondapi-c bindings (generated by build.rs)
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));

pub fn init(lib_path: &Path) -> ByondApi {
    unsafe { ByondApi::new(lib_path).expect("Failed to load library") }
}

pub fn init_from_library<L>(library: L) -> ByondApi
where
    L: Into<::libloading::Library>,
{
    unsafe { ByondApi::from_library(library).expect("Failed to load library") }
}