grid-rs 0.1.0

A library for interacting with host functions in the Slipstream runtime.
Documentation
  • Coverage
  • 91.67%
    11 out of 12 items documented1 out of 10 items with examples
  • Size
  • Source code size: 11.17 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.64 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 15s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • s3ndotxyz/grid-rs
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • notxorand
grid-rs-0.1.0 has been yanked.

Slipstream Rust SDK (Grid)

Overview

This is a library for using host functions from the Slipstream runtime. It's more or less a wrapper for linked Wasm imports.

Features

  • kvs. Provides access to the native in-runtime key-value store. You should be able to manage keys, values, and stores from within your functions. Note: stores are currently only available, one for each function.
  • time. We're enabling secure time for you to do things like event scheduling. This is a work in progress.

We have plans to enable a few other things such as message queues and web-sockets in the near future. Stay tuned!

Example

Here's a simple example of a function that stores a username and a vector of bytes in the key-value store:

use grid_rs::{kvs::Storage};
use serde::{Deserialize, Serialize};

#[grid_rs::main]
fn main(input: &[u8]) -> Result<Vec<u8>, String> {
    let input: MyInput = match serde_json::from_slice(input) {
        Ok(input) => input,
        Err(e) => {
            return Err(format!(
                "JSON deserialization failed: {e}. Input was: {}",
                String::from_utf8_lossy(input)));
        }
    };

    Storage::put(&input.username, &input.data);

    let output = MyOutput {
        status: "success".to_string(),
        result: input.data,
    };

    Ok(serde_json::to_vec(&output).unwrap())
}

#[derive(Deserialize)]
struct MyInput {
    username: String,
    data: Vec<u8>,
}

#[derive(Serialize)]
struct MyOutput {
    status: String,
    result: Vec<u8>,
}