#lib #space #webassembly #host #utilities #operator

space-lib

WebAssembly host functions for Space Operator

7 releases (4 breaking)

new 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

#401 in WebAssembly

Download history 21/week @ 2022-11-29 12/week @ 2022-12-06 54/week @ 2022-12-13 1/week @ 2022-12-20 20/week @ 2022-12-27 3/week @ 2023-01-03 13/week @ 2023-01-10 16/week @ 2023-01-17 12/week @ 2023-01-24 41/week @ 2023-01-31 11/week @ 2023-02-07 24/week @ 2023-02-14 10/week @ 2023-02-21 48/week @ 2023-02-28 62/week @ 2023-03-07 29/week @ 2023-03-14

150 downloads per month

Apache-2.0

7KB
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.2–1.9MB
~42K SLoC