pub struct Table<'l>(/* private fields */);
Expand description
Represents a lua table on the stack
Implementations§
Source§impl<'l> Table<'l>
impl<'l> Table<'l>
Sourcepub fn getp<T>(&self, p: *const T) -> Result<ValRef<'_>>
pub fn getp<T>(&self, p: *const T) -> Result<ValRef<'_>>
Get value with a lightuserdata key, commonly is a function pointer
Sourcepub fn setp<T, V: ToLua>(&self, k: *const T, v: V) -> Result<()>
pub fn setp<T, V: ToLua>(&self, k: *const T, v: V) -> Result<()>
Set value with a lightuserdata key
pub fn reference<V: ToLua>(&self, v: V) -> Result<Reference>
pub fn unreference(&self, r: Reference)
Sourcepub fn entry_count(&self) -> usize
pub fn entry_count(&self) -> usize
Count of the table entries
Sourcepub fn raw_geti(&self, i: impl Into<lua_Integer>) -> Result<ValRef<'l>>
pub fn raw_geti(&self, i: impl Into<lua_Integer>) -> Result<ValRef<'l>>
Get value by number index without metamethod triggers
Sourcepub fn raw_seti<V: ToLua>(&self, i: impl Into<lua_Integer>, v: V) -> Result<()>
pub fn raw_seti<V: ToLua>(&self, i: impl Into<lua_Integer>, v: V) -> Result<()>
Set value by number index without metamethod triggers
pub fn take_reference(&self, r: Reference) -> Result<ValRef<'l>>
Sourcepub fn raw_get<K: ToLua>(&self, key: K) -> Result<ValRef<'l>>
pub fn raw_get<K: ToLua>(&self, key: K) -> Result<ValRef<'l>>
Get the value associated to key
without metamethod triggers
Sourcepub fn raw_set<K: ToLua, V: ToLua>(&self, k: K, v: V) -> Result<()>
pub fn raw_set<K: ToLua, V: ToLua>(&self, k: K, v: V) -> Result<()>
Set value by any key without metamethod triggers
Sourcepub fn raw_insert<V: ToLua>(&self, i: usize, val: V) -> Result<()>
pub fn raw_insert<V: ToLua>(&self, i: usize, val: V) -> Result<()>
Insert an element into the array table, equivalent to table.insert
in lua
Sourcepub fn push<V: ToLua>(&self, val: V) -> Result<()>
pub fn push<V: ToLua>(&self, val: V) -> Result<()>
Push an element to end of the array part of a table, alias to self.raw_seti((self.raw_len() + 1) as i64, val)
Sourcepub fn pairs(&self) -> Result<impl Iterator<Item = (Value<'_>, Value<'_>)>>
pub fn pairs(&self) -> Result<impl Iterator<Item = (Value<'_>, Value<'_>)>>
Iterator to the table entries
Sourcepub fn set_closure<'a, K: ToLua, A: 'a, R: 'a, F: LuaMethod<'a, (), A, R> + 'static>(
&self,
name: K,
func: F,
) -> Result<&Self>
pub fn set_closure<'a, K: ToLua, A: 'a, R: 'a, F: LuaMethod<'a, (), A, R> + 'static>( &self, name: K, func: F, ) -> Result<&Self>
Alias to self.set(name, lua.new_closure(func))
Sourcepub fn set_function<'a, K: ToLua, ARGS: FromLuaMulti<'l>, RET: ToLuaMulti + 'l, F: Fn(&'l State, ARGS) -> RET + 'static>(
&self,
name: K,
func: F,
) -> Result<&Self>
pub fn set_function<'a, K: ToLua, ARGS: FromLuaMulti<'l>, RET: ToLuaMulti + 'l, F: Fn(&'l State, ARGS) -> RET + 'static>( &self, name: K, func: F, ) -> Result<&Self>
Alias to self.set(name, lua.new_function(func))
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