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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! A Rust SDK for writing [Webassembly] for [W3bstream].
//!
//! [W3bstream] is a general framework for connecting data generated
//! in the physical world to the blockchain world. [Webassembly] is selected as the
//! programming language for data processing.
//!
//! At a high level, W3bstream provides several Application Binary Interfaces (ABIs)
//! to enhance the [Webassembly] ability for developers:
//!
//!  * [streaming]: Reading or Writing the data in the stream
//!  * [database]: Storing or accessing the data in the database
//!  * [blockchain]: Writing or reading the contract on the blockchain
//!  * [logging][log]: Logging information or errors
//!
//! Guide level documentation is found on the [website].
//!
//! [W3bstream]: https://w3bstream.com/
//! [Webassembly]: https://webassembly.org/
//! [streaming]: crate::stream
//! [database]: crate::database
//! [blockchain]: crate::blockchain
//! [log]: crate::log
//! [website]: https://docs.w3bstream.com/
//!
//! # Examples
//!
//! Say "Hello World!" to the w3bstream:
//!
//! ```no_run
//!
//! ```
//!
pub mod blockchain;
pub mod database;
#[doc(hidden)]
pub mod host;
pub mod log;
pub mod stream;

// use std::mem;

// #[no_mangle]
// pub extern "C" fn alloc(size: i32) -> *mut u8 {
//     let mut buf: Vec<u8> = Vec::with_capacity(size as _);
//     let ptr = buf.as_mut_ptr();
//     mem::forget(buf);
//     return ptr;
// }

// #[no_mangle]
// pub extern "C" fn start(rid: i32) -> i32 {
//     log::log_info("hello_124");

//     // let data_u8 = match stream::get_data(rid as _) {
//     //     Ok(val) => val,
//     //     _ => return -1,
//     // };
//     // let data_str = match String::from_utf8(data_u8) {
//     //     Ok(val) => val,
//     //     _ => return -1,
//     // };
//     // log::log_info(&data_str);

//     log::log_error("bye_122");
//     return 0;
// }