WRT is a pure Rust implementation of a WebAssembly runtime that supports both the core WebAssembly specification and the WebAssembly Component Model. The project provides both a library (wrt
) for embedding the runtime in Rust applications and a standalone daemon (wrtd
) for executing WebAssembly modules.
- Core WebAssembly Support: Implements the WebAssembly 1.0 specification
- Component Model: Supports the WebAssembly Component Model for language-agnostic interoperability
no_std
Compatible: Can be used in environments without the standard library- Memory Safety: Provides safe memory management for WebAssembly modules
- Extensible: Easily extendable architecture for adding new features
wrt/
- Core WebAssembly runtime librarywrtd/
- WebAssembly Runtime Daemon for executing modulesexample/
- Example Component Model implementationdocs/
- Documentation including requirements and specificationsjustfile
- Command runner for development tasks
- Rust 1.70 or newer
- For development: just command runner
# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install just command runner
cargo install just
# Setup project dependencies
just setup
The easiest way to build the project is using the provided justfile:
# Build all crates
just build
# Build specific components
just build-wrt # Build only the library
just build-wrtd # Build only the daemon
just build-example # Build the example component
The project includes an example WebAssembly component that demonstrates basic functionality:
# Build and run the example
just build-example
just link-example
just run-example
Add WRT to your Cargo.toml:
[dependencies]
wrt = { git = "https://github.com/yourusername/wrt" }
Basic usage example:
use wrt::{Module, Engine, Result};
fn run_wasm_module(wasm_path: &str) -> Result<()> {
// Create a new engine
let mut engine = wrt::new_engine();
// Load WebAssembly bytes from a file
let wasm_bytes = std::fs::read(wasm_path)?;
// Parse the WebAssembly module
let module = Module::from_bytes(&wasm_bytes)?;
// Instantiate the module
let instance_idx = engine.instantiate(&module)?;
// Execute a function (assuming exported function "main" exists)
let results = engine.execute(instance_idx, 0, vec![])?;
println!("Execution completed with results: {:?}", results);
Ok(())
}
For more advanced examples, see the example directory.
The project uses the just
command runner to simplify development tasks.
# List all available commands
just --list
# Build everything
just build
# Run tests
just test
# Generate code coverage report
just coverage # Creates HTML report at target/coverage/html/index.html
# Code quality checks
just check
just check-imports # Check import organization
just check-udeps # Check for unused dependencies
just check-all # Run all checks
# Documentation
just docs-html # Build HTML documentation
just docs-pdf # Build PDF documentation (requires LaTeX)
# Clean build artifacts
just clean
The project follows these guidelines:
-
Imports are organized in this order:
- Standard library imports (std, core, alloc)
- External crates/third-party dependencies
- Internal modules (crate:: imports)
-
All public API should be documented following the format in CLAUDE.md.
-
Each module is organized by functionality with clear separation of concerns.
WRT uses two documentation systems:
-
Rust API Documentation: Generated with
cargo doc
cargo doc --open
-
Requirements and Specifications: Using Sphinx with sphinx-needs
just docs-html # Documentation will be available in docs/_build/html
This project includes GitHub Actions workflows that automatically run on pull requests and pushes to main:
- Build and test checks
- Code style enforcement
- Code coverage reporting (with Codecov integration)
- Documentation generation
- Security audit
- Unused dependency detection
This project is licensed under the MIT License - see the LICENSE file for details.