pub struct LuaTable { /* private fields */ }
Expand description
Represents a Lua table on the Lua stack.
Implementations§
Source§impl LuaTable
impl LuaTable
Sourcepub fn set_metatable(&self, context: &mut Context<'_>, meta: &LuaTable)
pub fn set_metatable(&self, context: &mut Context<'_>, meta: &LuaTable)
Set this table’s metatable.
Equivalent to the Lua setmetatable
function
Sourcepub fn set(&self, context: &mut Context<'_>, key: &dyn ToLua, value: &dyn ToLua)
pub fn set(&self, context: &mut Context<'_>, key: &dyn ToLua, value: &dyn ToLua)
Set a value in this table May call the __newindex metamethod
Equivalent to table[key] = value
in Lua
Sourcepub fn set_raw(
&self,
context: &mut Context<'_>,
key: &dyn ToLua,
value: &dyn ToLua,
)
pub fn set_raw( &self, context: &mut Context<'_>, key: &dyn ToLua, value: &dyn ToLua, )
Set a value in this table without invoking metamethods
Equivalent to the Lua rawset
function
Sourcepub fn get(&self, context: &mut Context<'_>, key: &dyn ToLua) -> LuaGeneric
pub fn get(&self, context: &mut Context<'_>, key: &dyn ToLua) -> LuaGeneric
Get a value from this table May call the __index metamethod
Equivalent to table[key]
in Lua
Sourcepub fn get_raw(&self, context: &mut Context<'_>, key: &dyn ToLua) -> LuaGeneric
pub fn get_raw(&self, context: &mut Context<'_>, key: &dyn ToLua) -> LuaGeneric
Get a value from this table without invoking metamethods
Equivalent to the Lua rawget
function
Sourcepub fn get_typed<T: FromLua>(
&self,
context: &mut Context<'_>,
key: &dyn ToLua,
) -> Option<T>
pub fn get_typed<T: FromLua>( &self, context: &mut Context<'_>, key: &dyn ToLua, ) -> Option<T>
Get a value from this table as type T
Sourcepub fn len(&self, context: &mut Context<'_>) -> i64
pub fn len(&self, context: &mut Context<'_>) -> i64
Count the number of elements in this table as an array
May call the __len
metamethod
Equivalent to the Lua #
operator
§Panics
This method will panic if this table has a __len
metamethod that does not return an integer
Sourcepub fn len_raw(&self, context: &mut Context<'_>) -> usize
pub fn len_raw(&self, context: &mut Context<'_>) -> usize
Count the number of elements in this table as an array without calling the __len
metamethod
Equivalent to the Lua rawlen
function
Sourcepub fn iter_array<F>(&self, context: &mut Context<'_>, func: F)
pub fn iter_array<F>(&self, context: &mut Context<'_>, func: F)
Iterate through every (i, value) pair where i is an integer and is continuous from 1 to this table’s length.
Similar to the Lua ipairs
function