#space #operator #wasm #serialization #deserialize #host #lib

space-lib

WebAssembly host functions for Space Operator

7 releases (4 breaking)

0.5.1 Mar 18, 2023
0.5.0 Mar 7, 2023
0.4.0 Mar 6, 2023
0.3.0 Mar 3, 2023
0.1.0 Nov 26, 2022

#608 in Encoding

Download history 5/week @ 2024-02-25 1/week @ 2024-03-03 5/week @ 2024-03-10 127/week @ 2024-03-24 66/week @ 2024-03-31

199 downloads per month

Apache-2.0

8KB
145 lines

space-lib

cargo add space-lib

This crate provides WebAssembly host functions and other utilities for Space Operator.

Example

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

use space_lib::Request;

let body = Request::get("https://www.spaceoperator.com")
    .call()?
    .into_string()?;

lib.rs:

This crate provides WebAssembly host functions and other utilities for Space Operator.

Example

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

use space_lib::Request;

let body = Request::get("https://www.spaceoperator.com")
    .call()?
    .into_string()?;

Dependencies

~1.5–2.2MB
~48K SLoC