1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
//! This crate allows you to embed [Yagna] WASI runtime inside your application. //! //! [Yagna]: https://github.com/golemfactory/yagna //! //! ## Quick start //! //! The usage is pretty straightforward. In your `Cargo.toml`, put `ya-runtime-wasi` //! as your dependency //! //! ```toml //! # Cargo.toml //! [dependencies] //! ya-runtime-wasi = "0.2" //! ``` //! //! You can now embed the runtime in your app like so //! //! ```rust,no_run //! 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(); //! ``` //! //! ## Obtaining handle to the deployed image //! //! 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 //! after [`ya_runtime_wasi::deploy`] and [`ya_runtime_wasi::start`] were run. //! //! [`DeployFile::load`]: struct.DeployFile.html#method.load //! [`ya_runtime_wasi::deploy`]: fn.deploy.html //! [`ya_runtime_wasi::start`]: fn.start.html //! //! ## Examples //! //! A good example of using `ya-runtime-wasi` embedding API can be found in the [`gfaas`] //! crate. //! //! [`gfaas`]: https://github.com/golemfactory/gfaas #![deny(missing_docs)] mod deploy; mod entrypoint; mod manifest; mod wasmtime_unit; pub use deploy::{deploy, ContainerVolume, DeployFile}; pub use entrypoint::{run, start};