1#![cfg_attr(all(test, nightly), feature(test))]
16
17#[cfg(all(test, nightly))]
18extern crate test;
19
20pub mod hostcalls;
21pub mod traits;
22pub mod types;
23
24mod allocator;
25mod dispatcher;
26mod logger;
27
28#[cfg(not(wasi_exec_model_reactor))]
30#[macro_export]
31macro_rules! main {
32 ($code:block) => {
33 #[cfg(target_os = "wasi")]
34 extern "C" {
35 fn __wasm_call_ctors();
36 }
37
38 #[no_mangle]
39 pub extern "C" fn _initialize() {
40 #[cfg(target_os = "wasi")]
41 unsafe {
42 __wasm_call_ctors();
43 }
44
45 $code;
46 }
47 };
48}
49
50#[cfg(wasi_exec_model_reactor)]
52#[macro_export]
53macro_rules! main {
54 ($code:block) => {
55 pub fn main() -> Result<(), Box<dyn std::error::Error>> {
56 $code;
57 Ok(())
58 }
59 };
60}
61
62pub fn set_log_level(level: types::LogLevel) {
63 logger::set_log_level(level);
64}
65
66pub fn set_root_context(callback: types::NewRootContext) {
67 dispatcher::set_root_context(callback);
68}
69
70pub fn set_stream_context(callback: types::NewStreamContext) {
71 dispatcher::set_stream_context(callback);
72}
73
74pub fn set_http_context(callback: types::NewHttpContext) {
75 dispatcher::set_http_context(callback);
76}
77
78#[no_mangle]
79pub extern "C" fn proxy_abi_version_0_2_1() {}