Batteries-included standard library modules for mlua.
Each module exposes a single module(lua) -> LuaResult<LuaTable> entry point.
Register individually or use [register_all] for convenience.
Platform support
This crate targets Unix server platforms (Linux, macOS). Windows is not a supported target.
Encoding — UTF-8 only (by design)
All path arguments are received as Rust [String] (UTF-8).
Non-UTF-8 Lua strings are rejected at the FromLua boundary.
Returned paths use to_string_lossy,
replacing any non-UTF-8 bytes with U+FFFD.
Why not raw bytes / OsStr?
mlua's FromLua for String performs UTF-8 validation — non-UTF-8
values produce FromLuaConversionError before reaching handler code.
Bypassing this would require accepting mlua::String + as_bytes()
in every function, converting through OsStr::from_bytes(), and
returning OsStr::as_bytes() back to Lua. This adds complexity
across all path-accepting functions for a scenario (non-UTF-8
filenames) that is rare on modern systems.
References:
- mlua
String::to_str(): https://docs.rs/mlua/latest/mlua/struct.String.html - mlua string internals: https://deepwiki.com/mlua-rs/mlua/2.3.4-strings
Quick start
use *;
let lua = new;
register_all.unwrap;
// Lua: std.json.encode({a = 1})
// Lua: std.env.get("HOME")
Custom configuration
// Requires the `sandbox` feature.
use *;
use Config;
use Sandboxed;
let lua = new;
let config = builder
.path_policy
.max_walk_depth
.build
.expect;
register_all_with.unwrap;