Expand description
The resource-controlled Lua runtime at the heart of Nitr: sandboxed states with memory/execution limits and the fixed runtime pool.
This crate is deliberately free of HTTP, database, and template
dependencies so it can be embedded on its own; the nitr facade crate
is the usual entrypoint for applications.
Re-exports§
pub use ns::ModuleFn;pub use ns::mount;pub use ns::nitr_table;
Modules§
- diag
- Terminal painting for diagnostics.
- ns
- The
nitrnamespace table: the single place where every Nitr API is exposed to Lua. Builtins, the application object, and the configuration snapshot mount as fields of the globalnitrtable; user-defined Rust extension modules mount one level down, undernitr.ext.*, so the standard library and user code can never collide. There are no other Nitr-provided globals.
Structs§
- Deadline
Handle - Grants additional execution budget to a runtime while it produces a streaming response: each chunk handed to the client resets the instruction-hook deadline, so the budget applies per chunk-production slice instead of to the total stream lifetime.
- Error
Info - A classified view of an
Error: what broke, where, and why, as separate fields instead of one interpolated string. - Runtime
- The Lua runtime that provides an interface to execute Lua scripts and manage Lua state.
It allows for registering Rust extension modules on the
nitrnamespace, running a configuration script, and calling Lua functions under the state’s execution budget. - Runtime
Guard - RAII guard over a checked-out
Runtime; returns it to the pool on drop. - Runtime
Opts - Options for configuring the Lua runtime.
- Runtime
Pool - A fixed pool of
Runtimes over an MPMC channel.
Enums§
- Error
- Errors returned by the Nitr library.
Functions§
- eval_
script Runtime::eval_scripton a bare state — for code that holds only theLuahandle, such as a builtin that loads the application into the state it runs in (nitr test’st.app()). The same text-only compile and the same in-context error rendering.- message_
token - The token a Lua error message points at, for caret placement: a parse
error’s
near 'users', or the symbol a runtime error names —attempt to call a nil value (method 'eexecute').near <eof>and messages without a quoted token yieldNone. - source_
snippet - Renders
lineof the file atpathwithcontextlines around it, in a gutter format that points at the failing line:
Type Aliases§
- Result
- Result type alias used across the Nitr library.