pub struct Coroutine { /* private fields */ }
Implementations§
Methods from Deref<Target = State>§
Sourcepub unsafe fn new_iter<'l, R: ToLuaMulti + 'l, I: Iterator<Item = R> + 'l, REF: ToLuaMulti>(
&self,
iter: I,
refs: REF,
) -> Result<LuaUserData<'_>>
pub unsafe fn new_iter<'l, R: ToLuaMulti + 'l, I: Iterator<Item = R> + 'l, REF: ToLuaMulti>( &self, iter: I, refs: REF, ) -> Result<LuaUserData<'_>>
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 + 'l, REF: ToLuaMulti>(
&self,
iter: I,
map: M,
refs: REF,
) -> Result<LuaUserData<'_>>
pub unsafe fn new_iter_map<'l, R: 'l, I: Iterator<Item = R> + 'l, MR: ToLuaMulti + 'l, M: Fn(&'l State, R) -> MR + 'l, REF: ToLuaMulti>( &self, iter: I, map: M, refs: REF, ) -> Result<LuaUserData<'_>>
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>(
&'l self,
fun: F,
) -> Result<Function<'_>>
pub fn new_function<'l, ARGS: FromLuaMulti<'l>, RET: ToLuaMulti + 'l, F: Fn(&'l State, ARGS) -> RET + 'static>( &'l 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>>
Sourcepub fn pushed<T: ToLuaMulti>(&self, results: T) -> Result<Pushed>
pub fn pushed<T: ToLuaMulti>(&self, results: T) -> Result<Pushed>
Push results to stack
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<'l: 'de, 'de, D: Deserializer<'de>>(
&'l self,
deserializer: D,
) -> Result<ValRef<'l>, LuaError>
pub fn load_from_deserializer<'l: 'de, 'de, D: Deserializer<'de>>( &'l self, deserializer: D, ) -> Result<ValRef<'l>, LuaError>
transcode a serializable value from deserializer into a lua value
Sourcepub fn array_metatable(&self) -> LuaResult<LuaTable<'_>>
pub fn array_metatable(&self) -> LuaResult<LuaTable<'_>>
A metatable attachable to a Lua table to systematically encode it as Array (instead of Map). As result, encoded Array will contain only sequence part of the table, with the same length as the # operator on that table.
Sourcepub fn null_value(&self) -> LuaValue<'_>
pub fn null_value(&self) -> LuaValue<'_>
A special value to encode/decode optional (none) values.
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 scope_userdata<T: UserData>(&self, data: T) -> Result<ScopeUserdata<'_>>
pub fn new_userdata_with_values<T: UserData, R: ToLuaMulti>( &self, data: T, refs: R, ) -> Result<LuaUserData<'_>>
Sourcepub fn new_userdata_untyped(
&self,
size: usize,
uv_count: usize,
) -> Result<LuaUserData<'_>>
pub fn new_userdata_untyped( &self, size: usize, uv_count: usize, ) -> Result<LuaUserData<'_>>
Create userdata with custom size
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<'_>
Sourcepub fn clear_slots(&self) -> Result<()>
pub fn clear_slots(&self) -> Result<()>
Clear the free slots, assign nil, and shrink the lua stack as much as possible
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 new_array_table(&self, narr: usize) -> Result<Table<'_>>
pub fn new_array_table(&self, narr: usize) -> Result<Table<'_>>
Create an array table
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>> + 'static>(
&self,
name: &str,
init: F,
global: bool,
) -> Result<()>
pub fn register_module<'a, F: Fn(&'a State) -> Result<Table<'a>> + 'static>( &self, name: &str, init: F, global: bool, ) -> Result<()>
Register your own lua module, which can be load by require
function in lua
pub fn main_state(&self) -> LuaThread<'_>
Sourcepub fn used_memory(&self) -> usize
pub fn used_memory(&self) -> usize
Returns the amount of memory (in bytes) currently used inside this Lua state
Sourcepub fn gc_collect(&self) -> Result<()>
pub fn gc_collect(&self) -> Result<()>
Do a full GC for lua
Sourcepub fn gc_is_running(&self) -> bool
pub fn gc_is_running(&self) -> bool
Returns true if the garbage collector is currently running automatically
Sourcepub fn gc_restart(&self)
pub fn gc_restart(&self)
Restarts the Lua GC if it is not running
Sourcepub fn gc_step(&self) -> Result<bool>
pub fn gc_step(&self) -> Result<bool>
Steps the garbage collector one indivisible step.
Returns true if this has finished a collection cycle.
Sourcepub fn gc_step_kbytes(&self, kbytes: c_int) -> Result<bool>
pub fn gc_step_kbytes(&self, kbytes: c_int) -> Result<bool>
Steps the garbage collector as though memory had been allocated.
if kbytes
is 0, then this is the same as calling gc_step
. Returns true if this step has
finished a collection cycle.
Sourcepub fn gc_set_pause(&self, pause: c_int) -> c_int
pub fn gc_set_pause(&self, pause: c_int) -> c_int
Sets the ‘pause’ value of the collector.
Returns the previous value of ‘pause’. More information can be found in the Lua documentation
Sourcepub fn gc_set_step_multiplier(&self, step_multiplier: c_int) -> c_int
pub fn gc_set_step_multiplier(&self, step_multiplier: c_int) -> c_int
Sets the ‘step multiplier’ value of the collector.
Returns the previous value of the ‘step multiplier’. More information can be found in the Lua documentation
Sourcepub fn gc_inc(
&self,
pause: c_int,
step_multiplier: c_int,
step_size: c_int,
) -> GCMode
pub fn gc_inc( &self, pause: c_int, step_multiplier: c_int, step_size: c_int, ) -> GCMode
Changes the collector to incremental mode with the given parameters.
Returns the previous mode (always GCMode::Incremental
in Lua < 5.4).
More information can be found in the Lua documentation
Sourcepub fn gc_gen(&self, minor_multiplier: c_int, major_multiplier: c_int) -> GCMode
pub fn gc_gen(&self, minor_multiplier: c_int, major_multiplier: c_int) -> GCMode
Changes the collector to generational mode with the given parameters.
Returns the previous mode. More information about the generational GC can be found in the Lua 5.4 documentation
Sourcepub fn backtrace(
&self,
co: Option<&State>,
msg: &str,
level: i32,
) -> Result<String>
pub fn backtrace( &self, co: Option<&State>, msg: &str, level: i32, ) -> Result<String>
Stack backtrace info
pub unsafe fn test_userdata_meta<T>( &self, i: Index, meta: MetatableKey, ) -> Option<&mut T>
pub fn stack(&self, n: i32) -> Option<lua_Debug>
Sourcepub fn do_string<S: AsRef<[u8]>>(
&self,
script: S,
name: Option<&str>,
) -> Result<()>
pub fn do_string<S: AsRef<[u8]>>( &self, script: S, name: Option<&str>, ) -> Result<()>
Load lua script and execute it