space_lib/lib.rs
1//! This crate provides WebAssembly host functions and other utilities for Space Operator.
2//!
3//! ## Example
4//!
5//! ```rust
6//! use space_lib::{space, Result};
7//! use serde::{Serialize, Deserialize};
8//!
9//! #[derive(Deserialize)]
10//! struct Input {
11//! value: usize,
12//! name: String,
13//! }
14//!
15//! #[derive(Serialize)]
16//! struct Output {
17//! value: usize,
18//! name: String,
19//! }
20//!
21//! #[space]
22//! fn main(input: Input) -> Result<Output> {
23//! let output = Output {
24//! value: input.value * 2,
25//! name: input.name.chars().rev().collect(),
26//! };
27//! Ok(output)
28//! }
29//! ```
30//!
31//! ## HTTP client
32//!
33//! ```rust
34//! use space_lib::Request;
35//!
36//! let body = Request::get("https://www.spaceoperator.com")
37//! .call()?
38//! .into_string()?;
39//! ```
40
41// Modules
42pub mod common;
43mod error;
44mod ffi;
45mod http;
46
47// Exports
48pub use error::{Error, Result};
49pub use http::{Request, Response};
50pub use rmp_serde;
51pub use space_macro::space;
52
53#[repr(C)]
54pub struct SpaceSlice {
55 pub len: usize,
56 pub ptr: *mut u8,
57}