Crate luajit

Source
Expand description

§LuaJIT RS

luajit_rs is a simple wrapper around the LuaJIT project, allowing it to be called from Rust easily and with minimal overhead. Most functions in this crate correspond directly to underlying Lua C API calls

§Examples

#[macro_use]
extern crate luajit;

use luajit::{c_int, State};

fn return_42(state: &mut State) -> c_int {
    state.push(42);

    1
}

pub fn main() {
    let mut state = State::new();
    state.open_libs();
    state.do_string(r#"print("Hello world!")"#);

    state.push(lua_fn!(return_42));
    state.set_global("return_42");
    state.do_string(r#"print(return_42())"#);
}

Re-exports§

pub use state::State;
pub use state::ThreadStatus;
pub use types::LuaFunction;
pub use types::LuaObject;

Modules§

ffi
state
types

Macros§

c_str
lua_fn
This macro is used to wrap a rust function in an extern "C" trampoline to automatically pass a State struct as the first argument instead of a lua_State raw pointer
lua_func
This macro can be used to automatically generate a luaL_Reg struct for the provided function, with name name
lua_method
This macro can be used to automatically generate a luaL_Reg struct for the provided method, with name name. It automatically reads an instances of struct $st from userdata and provides it as an argument.

Type Aliases§

c_int