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
31
32
33
34
35
36
#![feature(
    set_stdio,
    alloc_error_handler,
    core_intrinsics,
    panic_info_message,
    try_trait
)]

extern crate serde_cbor;
mod bytes;
mod debug;
pub mod error;
mod memory;
mod pointer;
mod response;
mod set_stdio;

pub use bytes::{FromBytes, ToBytes};
pub use pointer::{Dereferenceable, Pointer, Referenceable};
pub use response::{Bytes, Responsable};
pub use serde_cbor::{from_slice, to_vec, ObjectKey, Value};
pub use std::collections::BTreeMap;

pub use set_stdio::set_stdio;

// Note these must be defined in lib.rs
// https://users.rust-lang.org/t/how-to-export-rust-functions-from-child-module/11057/7
#[no_mangle]
pub unsafe fn __free(ptr: *mut u8) {
    memory::free(ptr);
}

#[no_mangle]
pub unsafe fn __malloc(size: usize) -> *mut u8 {
    memory::malloc(size)
}