eclair_bindings/
bindings.rs

1use ffi_opaque::opaque;
2use libc::size_t;
3
4opaque! {
5    pub struct Program;
6}
7
8#[repr(C, packed)]
9pub struct EclairString {
10    pub length: u32,
11    pub data: *const u8,
12}
13
14// NOTE: all the returned pointers are managed by the Eclair runtime!
15// Rust only needs to make sure it calls eclair_program_destroy / eclair_free_buffer
16// (using the Drop trait).
17// TODO figure out a way to defer specifying this linking target, now it's fixed to a single libeclair.a
18#[link(name = "eclair")]
19extern "C" {
20    pub fn eclair_program_init() -> *mut Program;
21    pub fn eclair_program_destroy(program: *mut Program);
22    pub fn eclair_program_run(program: *mut Program);
23    pub fn eclair_add_facts(
24        program: *mut Program,
25        fact_type: u32,
26        fact_data: *mut u32,
27        fact_count: size_t,
28    );
29    pub fn eclair_add_fact(program: *mut Program, fact_type: u32, fact_data: *mut u32);
30    pub fn eclair_get_facts(program: *mut Program, fact_type: u32) -> *mut u32;
31    pub fn eclair_free_buffer(fact_data: *mut u32);
32    pub fn eclair_fact_count(program: *mut Program, fact_type: u32) -> size_t;
33    pub fn eclair_encode_string(program: *mut Program, num_bytes: u32, bytes: *const u8) -> u32;
34    pub fn eclair_decode_string(program: *mut Program, str_index: u32) -> *const EclairString;
35}