Skip to main content

Crate nitr_core

Crate nitr_core 

Source
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 nitr namespace 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 global nitr table; user-defined Rust extension modules mount one level down, under nitr.ext.*, so the standard library and user code can never collide. There are no other Nitr-provided globals.

Structs§

DeadlineHandle
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.
ErrorInfo
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 nitr namespace, running a configuration script, and calling Lua functions under the state’s execution budget.
RuntimeGuard
RAII guard over a checked-out Runtime; returns it to the pool on drop.
RuntimeOpts
Options for configuring the Lua runtime.
RuntimePool
A fixed pool of Runtimes over an MPMC channel.

Enums§

Error
Errors returned by the Nitr library.

Functions§

eval_script
Runtime::eval_script on a bare state — for code that holds only the Lua handle, such as a builtin that loads the application into the state it runs in (nitr test’s t.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 yield None.
source_snippet
Renders line of the file at path with context lines around it, in a gutter format that points at the failing line:

Type Aliases§

Result
Result type alias used across the Nitr library.