1 unstable release
Uses new Rust 2024
| 0.1.0 | Oct 23, 2025 |
|---|
#1726 in WebAssembly
8MB
5.5K
SLoC
wash-runtime
wash-runtime is an opinionated Wasmtime wrapper that provides a runtime and workload API for executing WebAssembly components. It offers a simplified interface for embedding Wasm component execution in Rust applications with built-in support for WASI interfaces.
Features
- Component Model Runtime: Native support for WebAssembly Component Model using Wasmtime
- WASI Interface Support: Built-in plugins for WASI HTTP, Config, Logging, Blobstore, and Key-Value
- Workload API: High-level API for managing and executing component workloads
- Plugin System: Extensible architecture for custom capability providers
- OCI Integration: Optional support for pulling components from OCI registries
- Hot-Reload Ready: Designed for development workflows with fast iteration
Usage
Basic Example
use std::sync::Arc;
use std::collections::HashMap;
use wash_runtime::{
engine::Engine,
host::{HostBuilder, HostApi},
plugin::{
wasi_config::RuntimeConfig,
wasi_http::HttpServer,
},
types::{WorkloadStartRequest, Workload},
};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Create a Wasmtime engine
let engine = Engine::builder().build()?;
// Configure plugins
let http_plugin = HttpServer::new("127.0.0.1:8080".parse()?);
let runtime_config_plugin = RuntimeConfig::default();
// Build and start the host
let host = HostBuilder::new()
.with_engine(engine)
.with_plugin(Arc::new(http_plugin))?
.with_plugin(Arc::new(runtime_config_plugin))?
.build()?;
let host = host.start().await?;
// Start a workload
let req = WorkloadStartRequest {
workload: Workload {
namespace: "test".to_string(),
name: "test-workload".to_string(),
annotations: HashMap::new(),
service: None,
components: vec![],
host_interfaces: vec![],
volumes: vec![],
},
};
host.workload_start(req).await?;
Ok(())
}
Cargo Features
The crate supports the following cargo features:
wasi-http(default): HTTP client and server support viawasmtime-wasi-httpwasi-config(default): Runtime configuration interfacewasi-logging(default): Logging interfacewasi-blobstore(default): Blob storage interfacewasi-keyvalue(default): Key-value storage interfaceoci: OCI registry integration for pulling components
Architecture
wash-runtime provides three main abstractions:
- Engine: Wasmtime configuration and component compilation
- Host: Runtime environment with plugin management
- Workload: High-level API for managing component lifecycles
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Dependencies
~51–90MB
~1.5M SLoC