pub struct Function<'l>(/* private fields */);Expand description
Represents a lua function on the stack
Implementations§
Source§impl<'a> Function<'a>
impl<'a> Function<'a>
Methods from Deref<Target = ValRef<'l>>§
Sourcepub fn deserialize<T: Deserialize<'a>>(&'a self) -> Result<T, DesErr>
pub fn deserialize<T: Deserialize<'a>>(&'a self) -> Result<T, DesErr>
Deserialize a lua value
Sourcepub fn transcode<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>
pub fn transcode<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>
Transcode a lua value to another serialize format
pub fn state(&self) -> &'a State
pub fn is_nil(&self) -> bool
pub fn is_integer(&self) -> bool
pub fn is_table(&self) -> bool
pub fn is_function(&self) -> bool
pub fn check_safe_index(&self) -> Result<()>
pub fn to_safe_bytes(&self) -> Result<&'a [u8]>
pub fn to_safe_str(&self) -> Result<&'a str>
pub fn to_bytes(&self) -> Option<&[u8]>
pub fn to_str(&self) -> Option<&str>
pub fn to_string_lossy(&self) -> Option<Cow<'_, str>>
pub fn to_bool(&self) -> bool
pub fn to_integer(&self) -> lua_Integer
pub fn to_number(&self) -> lua_Number
pub fn to_pointer(&self) -> *const c_void
pub fn to_cstr_ptr(&self) -> *const c_char
pub fn check_type(&self, ty: Type) -> Result<()>
pub fn check_type2(&self, ty1: Type, ty2: Type) -> Result<()>
Sourcepub fn cast<T: FromLua<'a> + 'static>(&self) -> Result<T>
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
Sourcepub fn geti(&self, i: impl Into<lua_Integer>) -> Result<ValRef<'a>>
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
Sourcepub fn seti<V: ToLua>(&self, i: impl Into<lua_Integer>, v: V) -> Result<()>
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
Sourcepub fn len(&self) -> Result<ValRef<'a>>
pub fn len(&self) -> Result<ValRef<'a>>
Get length of the value, equivalent to return #self in lua
Sourcepub fn set<K: ToLua, V: ToLua>(&self, k: K, v: V) -> Result<()>
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
Sourcepub fn get<K: ToLua>(&self, key: K) -> Result<ValRef<'a>>
pub fn get<K: ToLua>(&self, key: K) -> Result<ValRef<'a>>
Get value associated to key, equivalent to return self[k] in lua
pub fn getopt<K: ToLua, V: FromLua<'a> + 'a>(&self, k: K) -> Result<Option<V>>
Sourcepub fn pcall<T: ToLuaMulti, R: FromLuaMulti<'a>>(&self, args: T) -> Result<R>
pub fn pcall<T: ToLuaMulti, R: FromLuaMulti<'a>>(&self, args: T) -> Result<R>
Call this value as a function
Sourcepub fn pcall_void<T: ToLuaMulti>(&self, args: T) -> Result<()>
pub fn pcall_void<T: ToLuaMulti>(&self, args: T) -> Result<()>
Invoke pcall() without return value
pub fn has_metatable(&self) -> bool
Sourcepub fn set_metatable(&self, t: Table<'_>) -> Result<()>
pub fn set_metatable(&self, t: Table<'_>) -> Result<()>
Set metatable for lua table or userdata
Sourcepub fn remove_metatable(&self)
pub fn remove_metatable(&self)
Remove metatable for lua table or userdata
Sourcepub fn call_metamethod<T: ToLuaMulti, R: FromLuaMulti<'a>>(
&self,
m: &str,
args: T,
) -> Result<R>
pub fn call_metamethod<T: ToLuaMulti, R: FromLuaMulti<'a>>( &self, m: &str, args: T, ) -> Result<R>
Call a metamethod
pub fn call_close_and_remove_metatable(&self) -> Result<()>
Sourcepub fn raw_equal(&self, other: &Self) -> bool
pub fn raw_equal(&self, other: &Self) -> bool
Tests whether two lua values are equal without metamethod triggers
Sourcepub fn raw_len(&self) -> usize
pub fn raw_len(&self) -> usize
Get length of the string/userdata/table without metamethod triggers