This Repository Is Deprecated
The library name is renamed to ssvm_process_interface.
Please follow the new crate for future versions.
Rust Process Interface Library
A Rust library that provides Rust to WebAssembly developers with syntax for running commands functionality when their Wasm is being executed on SecondState's SSVM.
From a high-level overview here, we are essentially building a process interface that will allow the native operating system (which SSVM is running on) to play a part in the runtime execution. Specifically, play a part in executing commands with arguments and environment values as part of Wasm execution.
How to use this library
Rust dependency
Developers will add the rust_process_interface_library
crate as a dependency to their Rust -> Wasm
applications. For example, add the following line to the application's Cargo.toml
file.
[dependencies]
rust_process_interface_library = "^0.1.3"
Developers will bring the Command
modules of rust_process_interface_library
into scope within their Rust -> Wasm
application's code. For example, adding the following code to the top of their main.rs
file.
use rust_process_interface_library::Command;
Execute commands with program name
Developers can then use syntax, such as the following, to execute commands such as using std::process::Command
. After compilation, the output target Wasm file will contain imports of host functions about running external commands.
Create a Command object
let mut cmd = new;
Append arguments
let mut cmd = new;
cmd.arg;
Or the following:
let cmd = new.arg;
Or the following:
let cmd = new.arg.arg;
Or the following:
let cmd = new.args;
Append environment variables
let mut cmd = new.arg.env;
Or the following:
use HashMap;
let mut cmd = new;
let mut hash: = new;
hash.insert;
hash.insert;
let mut cmd = new.arg.envs;
Append stdin
let mut cmd = new.stdin;
Or the following:
// Consider about the `\n` charactor in stdin strings.
let mut cmd = new.stdin.stdin;
Specify execution timeout
// Timeout values are in milliseconds.
let mut cmd = new
.stdin
.stdin
.stdin
.stdin
.timeout;
Execution and get outputs
Please remember to check for the return status of the child process.
let out = new
.stdin
.stdin
.stdin
.stdin
.stdin
.stdin
.stdin
.timeout
.output;
println!;
println!;
print!;
println!;
print!;
Crates.io
The official crate is available at crates.io.