#wasm #space #operator #serialize-deserialize #serialization #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

#1160 in Encoding

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

~0.7–1.5MB
~32K SLoC