Files
fluid/backend-rust/step3-finished-app/src/ffi.rs

27 lines
873 B
Rust
Raw Normal View History

2019-08-15 15:02:52 +03:00
// Description of inter-module communication
//
// Allows fluid module to call methods from sqlite module
2019-08-14 22:15:38 +03:00
#[link(wasm_import_module = "sqlite")]
extern "C" {
2019-08-15 15:02:52 +03:00
// Allocate chunk of SQLite memory, and return a pointer to that memory
#[link_name = "sqlite_allocate"]
2019-08-14 22:15:38 +03:00
pub fn allocate(size: usize) -> i32;
2019-08-15 15:02:52 +03:00
// Deallocate chunk of memory after it's not used anymore
#[link_name = "sqlite_deallocate"]
2019-08-14 22:15:38 +03:00
pub fn deallocate(ptr: i32, size: usize);
2019-08-15 15:02:52 +03:00
// Put 1 byte at ptr location in SQLite memory
#[link_name = "sqlite_store"]
2019-08-14 22:15:38 +03:00
pub fn store(ptr: i32, byte: u8);
2019-08-15 15:02:52 +03:00
// Read 1 byte from ptr location of SQLite memory
#[link_name = "sqlite_load"]
2019-08-14 22:15:38 +03:00
pub fn load(ptr: i32) -> u8;
2019-08-15 15:02:52 +03:00
// Call SQLite's invocation handler with data specified by pointer and size
#[link_name = "sqlite_invoke"]
pub fn invoke(ptr: i32, size: usize) -> i32;
2019-08-14 22:15:38 +03:00
}