| Crates.io | rsxtk |
| lib.rs | rsxtk |
| version | 0.4.2 |
| created_at | 2026-01-06 16:49:23.544158+00 |
| updated_at | 2026-01-23 16:22:54.840033+00 |
| description | A high-performance Rust WASM Toolkit for managing and running WASI scripts, WAT, and WASM modules. |
| homepage | https://github.com/jrmarcum/rsxtk |
| repository | https://github.com/jrmarcum/rsxtk |
| max_upload_size | |
| id | 2026277 |
| size | 907,997 |
rsxtk is a high-performance scripting toolkit that allows you to run single Rust files as standalone scripts with automatic dependency management, WASM/WASI compilation, and localized resource support.
Before installing rsxtk, you must have the Nightly Rust toolchain installed on your system.
Get started here: rust-lang.org/learn/get-started/
Ensure you have the Nightly Rust toolchain
rustup install nightly
rustup default nightly
and wasm32-wasip1 target installed:
rustup target add wasm32-wasip1
rsc/): A dedicated folder for local assets (HTML, CSV, JSON, etc.) that is automatically mirrored into the build environment.build.rs file located next to your script for complex build instructions.wasmtime-wasi error handling and exit status types._start (WASI). If missing, automatically lists callable functions.mod to call specific functions with arguments from the CLI.info command provides detailed function signatures (params and return types)..rs, .wasm, .wat, and .cwasm.rsxtk init my_script.rs
Add a crate (it will automatically find the latest version for you):
rsxtk add my_script.rs reqwest
Add a crate (it will automatically find the latest version for you):
rsxtk remove my_script.rs reqwest
Create a resource directory and place assets (like index.html) inside:
rsxtk resource my_script.rs
Place your local dependency files in the newly created rsc/ folder. You can reference them in your script like this:
Compiles to WASM and runs in a secure, sandboxed environment.
rsxtk run my_script.rs
Runs natively on the host using the Cargo script interface.
rsxtk csrun my_script.rs
| Command | Usage | Description |
|---|---|---|
init |
rsxtk init <name> |
Creates a new script with a manifest header. |
run |
rsxtk run <file> |
Runs file in the WASM/WASI sandbox. |
csrun |
rsxtk csrun <file> |
Runs file natively via cargo -Z script. |
resource |
rsxtk resource <file> |
Creates an rsc/ folder for local assets. |
add |
rsxtk add <file> <crate> |
Adds a dependency to the script manifest. |
remove |
rsxtk remove <file> <crate> |
Removes a dependency from the script manifest. |
list |
rsxtk list <file> |
Lists current dependencies in the script. |
fmt |
rsxtk fmt <file> |
Formats the Rust code inside the script (preserving manifest). |
build |
rsxtk build <file> <target> |
Compiles to wasi, wasm, or cwasm. |
clean |
rsxtk clean |
Wipes the .tk build cache. |
When you run a script, rsxtk performs the following steps:
Cargo project inside .tk/.rsc/ folder (if present) into the project root.build.rs (if present) into the project root.cargo to target wasm32-wasip1..cwasm artifact for near-native execution speed via Wasmtime.Create fib.rs:
---
[dependencies]
---
fn main() {
let mut a = 0;
let mut b = 1;
println!("Fibonacci sequence:");
for _ in 0..10 {
println!("{}", a);
let temp = a;
a = b;
b = temp + b;
}
}
Run: rsxtk run fib.rs
Create hello.wat:
(module
(import "wasi_snapshot_preview1" "fd_write" (func $fd_write (param i32 i32 i32 i32) (result i32)))
(memory 1)
(export "memory" (memory 0))
(data (i32.const 8) "Hello, Rosetta Code!\n")
(func $main (export "_start")
(i32.store (i32.const 0) (i32.const 8))
(i32.store (i32.const 4) (i32.const 21))
(call $fd_write (i32.const 1) (i32.const 0) (i32.const 1) (i32.const 24))
drop
)
)
Run: rsxtk run hello.wat
When you run a .rs file, rsxtk creates a hidden virtual Cargo project in the .tk/ directory. It manages dependencies, compiles the script to wasm32-wasip1, and then pre-compiles that WASM into a native .cwasm file for your specific CPU architecture.
On Windows, if your project is deep within a folder structure, you may encounter errors related to UNC paths (paths starting with \\?\).
G:\rsxtk_projects\).New-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Forcerustup target add wasm32-wasip1.rsxtk clean..wat file wasn't converted or a .cwasm is incompatible. Run rsxtk clean and try again.