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
//! This crate provides WebAssembly host functions and other utilities for Space Operator.
//!
//! ## Example
//!
//! ```rust
//! use space_lib::{space, Result};
//! use serde::{Serialize, Deserialize};
//!
//! #[derive(Deserialize)]
//! struct Input {
//!     value: usize,
//!     name: String,
//! }
//!
//! #[derive(Serialize)]
//! struct Output {
//!     value: usize,
//!     name: String,
//! }
//!
//! #[space]
//! fn main(input: Input) -> Result<Output> {
//!     let output = Output {
//!         value: input.value * 2,
//!         name: input.name.chars().rev().collect(),
//!     };
//!     Ok(output)
//! }
//! ```
//!
//! ## HTTP client
//!
//! ```rust
//! use space_lib::Request;
//!
//! let body = Request::get("https://www.spaceoperator.com")
//!     .call()?
//!     .into_string()?;
//! ```

// Modules
pub mod common;
mod error;
mod ffi;
mod http;

// Exports
pub use error::{Error, Result};
pub use http::{Request, Response};
pub use rmp_serde;
pub use space_macro::space;

#[repr(C)]
pub struct SpaceSlice {
    pub len: usize,
    pub ptr: *mut u8,
}