ya-runtime-wasi

Crates.ioya-runtime-wasi
lib.rsya-runtime-wasi
version0.2.1
sourcesrc
created_at2020-09-01 10:14:15.241392
updated_at2020-09-01 10:14:15.241392
descriptionYagna WASI runtime embedding API
homepagehttps://github.com/golemfactory/ya-runtime-wasi
repositoryhttps://github.com/golemfactory/ya-runtime-wasi
max_upload_size
id283368
size64,787
core-dev (github:golemfactory:core-dev)

documentation

https://docs.rs/ya-runtime-wasi

README

ya-runtime-wasi

Crates.io Docs.rs

This crate allows you to embed Yagna WASI runtime inside your application.

Quick start

The usage is pretty straightforward. In your Cargo.toml, put ya-runtime-wasi as your dependency

# Cargo.toml
[dependencies]
ya-runtime-wasi = "0.2"

You can now embed the runtime in your app like so

use std::path::Path;
use ya_runtime_wasi::*;

// In this example, we assume that `package.zip` contains a WASI binary
// called `hello.wasm`, and maps input/output to `/workdir`
let workspace = Path::new("workspace");
let module_name = "hello.wasm";
let package = Path::new("package.zip");

// Deploy package
deploy(&workspace, &package).unwrap();

// Start the runtime
start(&workspace).unwrap();

// Execute the binary
run(
    &workspace,
    &module_name,
    vec![
        "/workdir/input".to_string(),
        "/workdir/output".to_string(),
    ],
).unwrap();

Examples

A good example of using ya-runtime-wasi embedding API can be found in the gfaas crate.

Commit count: 100

cargo fmt