This crate allows you to embed Yagna WASI runtime inside your application.
The usage is pretty straightforward. In your
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` which also our entrypoint into the package, and // maps input/output to `/workdir` let workspace = Path::new("workspace"); let entrypoint = "hello"; let package = Path::new("package.zip"); // Deploy package deploy(&workspace, &package).unwrap(); // Start the runtime start(&workspace).unwrap(); // Execute the binary run( &workspace, &entrypoint, vec![ "/workdir/input".into(), "/workdir/output".into(), ], ).unwrap();
A handle to the deployed image, i.e., the path to the image as well as a list of mapped
container volumes, can be obtained using
DeployFile::load function invoked
ya_runtime_wasi::start were run.
A good example of using
ya-runtime-wasi embedding API can be found in the
Represents name and path to the mapped volume in the container.
Represents deployed Yagna Wasm image with set up volumes inside the container.
Deploys the Wasm image into the workspace.
Instantiates and executes the deployed image using Wasmtime runtime.
Validates the deployed image.