Struct ezlua::prelude::LuaState

source ·
pub struct LuaState {
    pub base: Index,
    /* private fields */
}
Expand description

Safe wrapper for operation to lua_State

Fields§

§base: Index

Implementations§

source§

impl State

source

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

source

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

source

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

source

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

source

pub fn new_closure0<'l, RET: ToLuaMulti + 'l, FN: Fn(&'l State) -> RET + 'static>( &'l self, f: FN ) -> Result<Function<'l>>

source

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>>

source

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>>

source

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>>

source

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>>

source

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>>

source

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>>

source

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>>

source

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>>

source

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>>

source

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

source

pub fn pushed<T: ToLuaMulti>(&self, results: T) -> Result<Pushed>

Push results to stack

source§

impl State

source

pub fn serialize_to_val<V: Serialize>(&self, v: V) -> LuaResult<ValRef<'_>>

convert a serializable value into a lua value

source

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

source

pub fn register_usertype<U: UserData>(&self) -> Result<Table<'_>>

Register a metatable of UserData into the C registry and return it

source

pub fn new_userdata<T: UserData>(&self, data: T) -> Result<LuaUserData<'_>>

Create userdata

source

pub fn new_userdata_with_values<T: UserData, R: ToLua, const N: usize>( &self, data: T, refs: [R; N] ) -> Result<LuaUserData<'_>>

source§

impl State

source

pub unsafe fn from_raw_state(state: *mut lua_State) -> Self

source

pub fn raw_state(&self) -> *mut lua_State

source

pub fn stack_top(&self) -> i32

source

pub fn check_stack(&self, n: i32) -> Result<()>

source

pub fn check_type(&self, i: Index, ty: Type) -> Result<()>

source

pub fn up_value(&self, i: Index) -> ValRef<'_>

source

pub fn arg_val(&self, i: Index) -> Option<ValRef<'_>>

source

pub fn to_safe_bytes(&self, i: Index) -> Option<&[u8]>

source

pub fn registry(&self) -> Table<'_>

Get the C registry table

source

pub fn new_val<V: ToLua>(&self, val: V) -> Result<ValRef<'_>>

Create a new lua value

source

pub fn new_value<V: ToLua>(&self, val: V) -> Result<Value<'_>>

Create a new lua value, return as Value rather than ValRef

source

pub fn new_table_with_size(&self, narr: c_int, nrec: c_int) -> Result<Table<'_>>

Create a lua table and specify the size

source

pub fn new_table(&self) -> Result<Table<'_>>

Create a lua table

source

pub fn new_string<S: AsRef<[u8]>>(&self, s: S) -> Result<LuaString<'_>>

Create a lua string

source

pub fn load<S: AsRef<[u8]>>( &self, s: S, name: Option<&str> ) -> Result<Function<'_>>

Load script string or bytecode

source

pub fn load_file<P: AsRef<Path>>(&self, path: P) -> Result<Function<'_>>

Create function from script file

source

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

source

pub fn global(&self) -> Table<'_>

Get the lua global table

source

pub fn gc_collect(&self) -> Result<()>

Do a full GC for lua

source

pub fn backtrace(&self, co: Option<&State>, msg: &str, level: i32) -> String

Stack backtrace info

source

pub unsafe fn test_userdata_meta<T>( &self, i: Index, meta: MetatableKey ) -> Option<&mut T>

source

pub fn trace_error(&self, s: Option<&Self>) -> Cow<'_, str>

[-1, +1, -]

source

pub fn stack(&self, n: i32) -> Option<lua_Debug>

source

pub unsafe fn error_string(self, e: impl AsRef<str>) -> !

source

pub unsafe fn raise_error(self, e: impl Debug) -> !

source

pub unsafe extern "C" fn traceback_c(l: *mut lua_State) -> i32

source§

impl State

source

pub fn do_string<S: AsRef<[u8]>>( &self, script: S, name: Option<&str> ) -> Result<()>

Load lua script and execute it

source

pub fn registry_value<V: ToLua>(&self, val: V) -> Result<RegVal>

source

pub fn safe_index(&self, i: Index) -> bool

source

pub fn free_slots(&self) -> Ref<'_, Slots<i32>>

Trait Implementations§

source§

impl Debug for State

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for State

§

impl !Send for State

§

impl !Sync for State

§

impl Unpin for State

§

impl UnwindSafe for State

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UserDataTrans<T> for T

§

type Read = &'a T

§

type Write = &'a mut T

source§

fn trans(udata: T) -> T

source§

const INIT_USERDATA: Option<fn(_: &State, _: &mut Self)> = None

source§

unsafe fn when_drop(&mut self)