pub struct LuaState {
pub base: Index,
/* private fields */
}Expand description
Safe wrapper for operation to lua_State
Fields§
§base: IndexImplementations§
source§impl State
impl State
sourcepub unsafe fn new_iter<'l, R: ToLuaMulti + 'l, I: Iterator<Item = R> + 'l, REF: ToLua, const C: usize>(
&self,
iter: I,
refs: [REF; C]
) -> Result<Function<'_>>
pub unsafe fn new_iter<'l, R: ToLuaMulti + 'l, I: Iterator<Item = R> + 'l, REF: ToLua, const C: usize>( &self, iter: I, refs: [REF; C] ) -> Result<Function<'_>>
Create an iterator with non-static reference, you should ensure that these references
is valid via the refs argument, which is be referenced by the iter closure’s upvalues
sourcepub unsafe fn new_iter_map<'l, R: 'l, I: Iterator<Item = R> + 'l, MR: ToLuaMulti + 'l, M: Fn(&'l State, R) -> MR, REF: ToLua, const C: usize>(
&'l self,
iter: I,
map: M,
refs: [REF; C]
) -> Result<Function<'_>>
pub unsafe fn new_iter_map<'l, R: 'l, I: Iterator<Item = R> + 'l, MR: ToLuaMulti + 'l, M: Fn(&'l State, R) -> MR, REF: ToLua, const C: usize>( &'l self, iter: I, map: M, refs: [REF; C] ) -> Result<Function<'_>>
Like State::new_iter, and you can specify a map function
sourcepub fn new_function<'l, ARGS: FromLuaMulti<'l>, RET: ToLuaMulti + 'l, F: Fn(&'l State, ARGS) -> RET + 'static>(
&self,
fun: F
) -> Result<Function<'_>>
pub fn new_function<'l, ARGS: FromLuaMulti<'l>, RET: ToLuaMulti + 'l, F: Fn(&'l State, ARGS) -> RET + 'static>( &self, fun: F ) -> Result<Function<'_>>
Bind a rust function(closure) with uniform argument types
sourcepub fn new_closure<'l, A: 'l, R: 'l, F: LuaMethod<'l, (), A, R> + 'static>(
&self,
fun: F
) -> Result<Function<'_>>
pub fn new_closure<'l, A: 'l, R: 'l, F: LuaMethod<'l, (), A, R> + 'static>( &self, fun: F ) -> Result<Function<'_>>
Bind a rust function(closure) with flexible argument types
pub fn new_closure0<'l, RET: ToLuaMulti + 'l, FN: Fn(&'l State) -> RET + 'static>( &'l self, f: FN ) -> Result<Function<'l>>
pub fn new_closure1<'l, RET: ToLuaMulti + 'l, A: FromLua<'l>, FN: Fn(&'l State, A) -> RET + 'static>( &'l self, f: FN ) -> Result<Function<'l>>
pub fn new_closure2<'l, RET: ToLuaMulti + 'l, A: FromLua<'l>, B: FromLua<'l>, FN: Fn(&'l State, A, B) -> RET + 'static>( &'l self, f: FN ) -> Result<Function<'l>>
pub fn new_closure3<'l, RET: ToLuaMulti + 'l, A: FromLua<'l>, B: FromLua<'l>, C: FromLua<'l>, FN: Fn(&'l State, A, B, C) -> RET + 'static>( &'l self, f: FN ) -> Result<Function<'l>>
pub fn new_closure4<'l, RET: ToLuaMulti + 'l, A: FromLua<'l>, B: FromLua<'l>, C: FromLua<'l>, D: FromLua<'l>, FN: Fn(&'l State, A, B, C, D) -> RET + 'static>( &'l self, f: FN ) -> Result<Function<'l>>
pub fn new_closure5<'l, RET: ToLuaMulti + 'l, A: FromLua<'l>, B: FromLua<'l>, C: FromLua<'l>, D: FromLua<'l>, E: FromLua<'l>, FN: Fn(&'l State, A, B, C, D, E) -> RET + 'static>( &'l self, f: FN ) -> Result<Function<'l>>
pub fn new_closure6<'l, RET: ToLuaMulti + 'l, A: FromLua<'l>, B: FromLua<'l>, C: FromLua<'l>, D: FromLua<'l>, E: FromLua<'l>, F: FromLua<'l>, FN: Fn(&'l State, A, B, C, D, E, F) -> RET + 'static>( &'l self, f: FN ) -> Result<Function<'l>>
pub fn new_closure7<'l, RET: ToLuaMulti + 'l, A: FromLua<'l>, B: FromLua<'l>, C: FromLua<'l>, D: FromLua<'l>, E: FromLua<'l>, F: FromLua<'l>, G: FromLua<'l>, FN: Fn(&'l State, A, B, C, D, E, F, G) -> RET + 'static>( &'l self, f: FN ) -> Result<Function<'l>>
pub fn new_closure8<'l, RET: ToLuaMulti + 'l, A: FromLua<'l>, B: FromLua<'l>, C: FromLua<'l>, D: FromLua<'l>, E: FromLua<'l>, F: FromLua<'l>, G: FromLua<'l>, H: FromLua<'l>, FN: Fn(&'l State, A, B, C, D, E, F, G, H) -> RET + 'static>( &'l self, f: FN ) -> Result<Function<'l>>
pub fn new_closure9<'l, RET: ToLuaMulti + 'l, A: FromLua<'l>, B: FromLua<'l>, C: FromLua<'l>, D: FromLua<'l>, E: FromLua<'l>, F: FromLua<'l>, G: FromLua<'l>, H: FromLua<'l>, I: FromLua<'l>, FN: Fn(&'l State, A, B, C, D, E, F, G, H, I) -> RET + 'static>( &'l self, f: FN ) -> Result<Function<'l>>
pub fn new_closure10<'l, RET: ToLuaMulti + 'l, A: FromLua<'l>, B: FromLua<'l>, C: FromLua<'l>, D: FromLua<'l>, E: FromLua<'l>, F: FromLua<'l>, G: FromLua<'l>, H: FromLua<'l>, I: FromLua<'l>, J: FromLua<'l>, FN: Fn(&'l State, A, B, C, D, E, F, G, H, I, J) -> RET + 'static>( &'l self, f: FN ) -> Result<Function<'l>>
source§impl State
impl State
sourcepub fn pushed<T: ToLuaMulti>(&self, results: T) -> Result<Pushed>
pub fn pushed<T: ToLuaMulti>(&self, results: T) -> Result<Pushed>
Push results to stack
source§impl State
impl State
sourcepub fn serialize_to_val<V: Serialize>(&self, v: V) -> LuaResult<ValRef<'_>>
pub fn serialize_to_val<V: Serialize>(&self, v: V) -> LuaResult<ValRef<'_>>
convert a serializable value into a lua value
sourcepub fn load_from_deserializer<'de, D: Deserializer<'de>>(
&'de self,
deserializer: D
) -> Result<ValRef<'de>, LuaError>
pub fn load_from_deserializer<'de, D: Deserializer<'de>>( &'de self, deserializer: D ) -> Result<ValRef<'de>, LuaError>
transcode a serializable value from deserializer into a lua value
source§impl State
impl State
sourcepub fn register_usertype<U: UserData>(&self) -> Result<Table<'_>>
pub fn register_usertype<U: UserData>(&self) -> Result<Table<'_>>
Register a metatable of UserData into the C registry and return it
sourcepub fn new_userdata<T: UserData>(&self, data: T) -> Result<LuaUserData<'_>>
pub fn new_userdata<T: UserData>(&self, data: T) -> Result<LuaUserData<'_>>
Create userdata
pub fn new_userdata_with_values<T: UserData, R: ToLua, const N: usize>( &self, data: T, refs: [R; N] ) -> Result<LuaUserData<'_>>
source§impl State
impl State
pub unsafe fn from_raw_state(state: *mut lua_State) -> Self
pub fn raw_state(&self) -> *mut lua_State
pub fn stack_top(&self) -> i32
pub fn check_stack(&self, n: i32) -> Result<()>
pub fn check_type(&self, i: Index, ty: Type) -> Result<()>
pub fn up_value(&self, i: Index) -> ValRef<'_>
pub fn arg_val(&self, i: Index) -> Option<ValRef<'_>>
pub fn to_safe_bytes(&self, i: Index) -> Option<&[u8]>
sourcepub fn new_table_with_size(&self, narr: c_int, nrec: c_int) -> Result<Table<'_>>
pub fn new_table_with_size(&self, narr: c_int, nrec: c_int) -> Result<Table<'_>>
Create a lua table and specify the size
sourcepub fn load<S: AsRef<[u8]>>(
&self,
s: S,
name: Option<&str>
) -> Result<Function<'_>>
pub fn load<S: AsRef<[u8]>>( &self, s: S, name: Option<&str> ) -> Result<Function<'_>>
Load script string or bytecode
sourcepub fn load_file<P: AsRef<Path>>(&self, path: P) -> Result<Function<'_>>
pub fn load_file<P: AsRef<Path>>(&self, path: P) -> Result<Function<'_>>
Create function from script file
sourcepub fn register_module<'a, F: Fn(&'a State) -> Result<Table<'a>>>(
&self,
name: &str,
init: F,
global: bool
) -> Result<()>
pub fn register_module<'a, F: Fn(&'a State) -> Result<Table<'a>>>( &self, name: &str, init: F, global: bool ) -> Result<()>
Register your own lua module, which can be load by require function in lua
sourcepub fn gc_collect(&self) -> Result<()>
pub fn gc_collect(&self) -> Result<()>
Do a full GC for lua
sourcepub fn backtrace(&self, co: Option<&State>, msg: &str, level: i32) -> String
pub fn backtrace(&self, co: Option<&State>, msg: &str, level: i32) -> String
Stack backtrace info