lune_std/
lib.rs

1#![allow(clippy::cargo_common_metadata)]
2
3use mlua::prelude::*;
4
5mod global;
6mod globals;
7mod library;
8mod luaurc;
9
10pub use self::global::LuneStandardGlobal;
11pub use self::globals::version::set_global_version;
12pub use self::library::LuneStandardLibrary;
13
14/**
15    Injects all standard globals into the given Lua state / VM.
16
17    This includes all enabled standard libraries, which can
18    be used from Lua with `require("@lune/library-name")`.
19
20    # Errors
21
22    Errors when out of memory, or if *default* Lua globals are missing.
23*/
24pub fn inject_globals(lua: &Lua) -> LuaResult<()> {
25    for global in LuneStandardGlobal::ALL {
26        lua.globals().set(global.name(), global.create(lua)?)?;
27    }
28    Ok(())
29}