Function

Struct Function 

Source
pub struct Function<'l>(/* private fields */);
Expand description

Represents a lua function on the stack

Implementations§

Source§

impl<'a> Function<'a>

Source

pub fn get_upvalue(&self, i: Index) -> Result<Option<ValRef<'a>>>

Source

pub fn get_upvalue_name( &self, i: Index, ) -> Result<Option<(ValRef<'a>, &'a str)>>

Source

pub fn set_upvalue(&self, i: Index, val: impl ToLua) -> Result<()>

Source

pub fn upvalues(&self) -> Result<Vec<ValRef<'a>>>

Source

pub fn dump(&self, strip: bool) -> Vec<u8>

Dumps the function as a binary chunk.

If strip is true, the binary representation may not include all debug information about the function, to save space.

Methods from Deref<Target = ValRef<'l>>§

Source

pub fn deserialize<T: Deserialize<'a>>(&'a self) -> Result<T, DesErr>

Deserialize a lua value

Source

pub fn transcode<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Transcode a lua value to another serialize format

Source

pub fn state(&self) -> &'a State

Source

pub fn type_of(&self) -> Type

Type of this value

Source

pub fn is_nil(&self) -> bool

Source

pub fn is_integer(&self) -> bool

Source

pub fn is_table(&self) -> bool

Source

pub fn is_function(&self) -> bool

Source

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

Source

pub fn to_safe_bytes(&self) -> Result<&'a [u8]>

Source

pub fn to_safe_str(&self) -> Result<&'a str>

Source

pub fn to_bytes(&self) -> Option<&[u8]>

Source

pub fn to_str(&self) -> Option<&str>

Source

pub fn to_string_lossy(&self) -> Option<Cow<'_, str>>

Source

pub fn to_bool(&self) -> bool

Source

pub fn to_integer(&self) -> lua_Integer

Source

pub fn to_number(&self) -> lua_Number

Source

pub fn to_pointer(&self) -> *const c_void

Source

pub fn to_cstr_ptr(&self) -> *const c_char

Source

pub fn tostring(&self) -> Cow<'_, str>

Call tostring if this value is not a string

Source

pub fn index(&self) -> Index

Index number of this value on the lua stack

Source

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

Source

pub fn check_type2(&self, ty1: Type, ty2: Type) -> Result<()>

Source

pub fn cast<T: FromLua<'a> + 'static>(&self) -> Result<T>

Alias to cast_into(), not take the ownship, but only convert to static-lifetime types

Source

pub fn geti(&self, i: impl Into<lua_Integer>) -> Result<ValRef<'a>>

Get value associated to integer key, equivalent to return self[i] in lua

Source

pub fn seti<V: ToLua>(&self, i: impl Into<lua_Integer>, v: V) -> Result<()>

Set value with integer key, equivalent to self[i] = v in lua

Source

pub fn len(&self) -> Result<ValRef<'a>>

Get length of the value, equivalent to return #self in lua

Source

pub fn set<K: ToLua, V: ToLua>(&self, k: K, v: V) -> Result<()>

Set value with any key, equivalent to self[k] = v in lua

Source

pub fn get<K: ToLua>(&self, key: K) -> Result<ValRef<'a>>

Get value associated to key, equivalent to return self[k] in lua

Source

pub fn getopt<K: ToLua, V: FromLua<'a> + 'a>(&self, k: K) -> Result<Option<V>>

Source

pub fn pcall<T: ToLuaMulti, R: FromLuaMulti<'a>>(&self, args: T) -> Result<R>

Call this value as a function

Source

pub fn pcall_void<T: ToLuaMulti>(&self, args: T) -> Result<()>

Invoke pcall() without return value

Source

pub fn has_metatable(&self) -> bool

Source

pub fn metatable(&self) -> Result<Option<Table<'a>>>

Get metatable of lua table or userdata

Source

pub fn set_metatable(&self, t: Table<'_>) -> Result<()>

Set metatable for lua table or userdata

Source

pub fn remove_metatable(&self)

Remove metatable for lua table or userdata

Source

pub fn call_metamethod<T: ToLuaMulti, R: FromLuaMulti<'a>>( &self, m: &str, args: T, ) -> Result<R>

Call a metamethod

Source

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

Source

pub fn raw_equal(&self, other: &Self) -> bool

Tests whether two lua values are equal without metamethod triggers

Source

pub fn raw_len(&self) -> usize

Get length of the string/userdata/table without metamethod triggers

Source

pub fn as_table(&self) -> Option<&Table<'a>>

Source

pub fn as_function(&self) -> Option<&Function<'a>>

Source

pub fn as_string(&self) -> Option<&LuaString<'a>>

Source

pub fn as_thread(&self) -> Option<&LuaThread<'a>>

Source

pub fn as_userdata(&self) -> Option<&LuaUserData<'a>>

Source

pub fn airth_add(&self, rhs: impl ToLua) -> Result<Self>

Source

pub fn airth_sub(&self, rhs: impl ToLua) -> Result<Self>

Source

pub fn airth_mul(&self, rhs: impl ToLua) -> Result<Self>

Source

pub fn airth_div(&self, rhs: impl ToLua) -> Result<Self>

Source

pub fn airth_rem(&self, rhs: impl ToLua) -> Result<Self>

Source

pub fn airth_bitand(&self, rhs: impl ToLua) -> Result<Self>

Source

pub fn airth_bitor(&self, rhs: impl ToLua) -> Result<Self>

Source

pub fn airth_bitxor(&self, rhs: impl ToLua) -> Result<Self>

Source

pub fn airth_shl(&self, rhs: impl ToLua) -> Result<Self>

Source

pub fn airth_shr(&self, rhs: impl ToLua) -> Result<Self>

Source

pub fn arith_neg(&self) -> Result<Self>

Source

pub fn arith_not(&self) -> Result<Self>

Source

pub fn idiv(&self, rhs: impl ToLua) -> Result<Self>

Source

pub fn pow(&self, rhs: impl ToLua) -> Result<Self>

Trait Implementations§

Source§

impl<'l> Clone for Function<'l>

Source§

fn clone(&self) -> Function<'l>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'l> Debug for Function<'l>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'l> Deref for Function<'l>

Source§

type Target = ValRef<'l>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a> FromLua<'a> for Function<'a>

Source§

fn from_lua(_: &'a State, val: ValRef<'a>) -> Result<Self>

Source§

const TYPE_NAME: &'static str = _

Source§

impl<'a> Into<ValRef<'a>> for Function<'a>

Source§

fn into(self) -> ValRef<'a>

Converts this type into the (usually inferred) input type.
Source§

impl<'a> ToLua for Function<'a>

Source§

fn to_lua<'a>(self, lua: &'a State) -> Result<ValRef<'a>>

Source§

impl<'a> TryFrom<ValRef<'a>> for Function<'a>

Source§

type Error = Error

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

fn try_from(val: ValRef<'a>) -> Result<Self>

Performs the conversion.

Auto Trait Implementations§

§

impl<'l> Freeze for Function<'l>

§

impl<'l> !RefUnwindSafe for Function<'l>

§

impl<'l> !Send for Function<'l>

§

impl<'l> !Sync for Function<'l>

§

impl<'l> Unpin for Function<'l>

§

impl<'l> !UnwindSafe for Function<'l>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<'a, T> FromLuaMulti<'a> for T
where T: FromLua<'a>,

Source§

const COUNT: usize = 1usize

Source§

fn from_lua_multi(s: &'a State, begin: i32) -> Result<T, Error>

Source§

impl<T, U> Into<U> for T
where 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToLuaMulti for T
where T: ToLua,

Source§

const VALUE_COUNT: Option<usize> = const VALUE_COUNT: Option<usize> = Some(1);

Count of values to be pushed to lua stack
Source§

fn push_multi(self, s: &State) -> Result<usize, Error>

Define how to push values onto lua stack
Source§

fn value_count(&self) -> Option<usize>

Get the count of values to be pushed to lua stack, with self instance
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.