Crates.io | space-lib |
lib.rs | space-lib |
version | 0.5.1 |
source | src |
created_at | 2022-11-26 19:42:14.782152 |
updated_at | 2023-03-18 20:32:40.698327 |
description | WebAssembly host functions for Space Operator |
homepage | |
repository | |
max_upload_size | |
id | 723431 |
size | 18,650 |
cargo add space-lib
This crate provides WebAssembly host functions and other utilities for Space Operator.
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)
}
use space_lib::Request;
let body = Request::get("https://www.spaceoperator.com")
.call()?
.into_string()?;