rhue 1.0.0

An embeddable, Luau-flavoured scripting language for Rust: register functions, run scripts, check types
Documentation

I write a lot of Luau and a lot of Rust, and wanted the first one inside the second, so here we are. Rhue looks like Luau (same syntax, same --!strict gradual typing), embeds about as easily as Rhai, and runs on its own register VM. This is the crate you want, the rest are its insides.

[dependencies]
rhue = "1"
use rhue::Engine;

let mut engine = Engine::new();
engine.register("shout", |s: String| s.to_uppercase() + "!");

let out: String = engine.eval_as(r#"return shout("hello from rhue")"#).unwrap();
assert_eq!(out, "HELLO FROM RHUE!");

What you get:

  • Typed register — parameters and results convert on their own, and the type checker learns each function's signature from its Rust types
  • #[derive(UserData)] — Rust structs as script objects, with methods and a constructor
  • Calling back — take &mut Context first and a native can call script functions, errors pass through ? unchanged
  • Sandboxing — instruction and memory limits, separate environments so plugins can't see each other's globals, a sandbox-safe os
  • Modules — require from source, a loader, or compiled bytecode, with types that travel with them
  • Tasks — natives that pause a script until the host resumes it, and Roblox's task library on a clock you drive
  • Async — async Rust functions scripts can wait on, eval_async, and interrupts from any thread
  • Hot reload — swap a module for new code while scripts run, state carries over
  • Debug hooks — line, call and return events, locals, upvalues, evaluating in a frame
  • serde — behind the serde feature, convert any Serialize/Deserialize type to script values and back
use rhue::Engine;

let mut engine = Engine::new();
engine.set_instruction_limit(Some(100_000));
engine.set_memory_limit(Some(1 << 20));

let err = engine.eval("while true do end").unwrap_err();
assert!(err.to_string().contains("instruction limit"));

The repo's README has the full tour of the language, the tooling (CLI, language server, debugger) and the benchmarks. The API docs are on docs.rs, and the site's at rhue.dev.

Needs Rust 1.88 or newer.

License

MIT or Apache-2.0, at your option.