Struct LuaTable

Source
pub struct LuaTable { /* private fields */ }
Expand description

Represents a Lua table on the Lua stack.

Implementations§

Source§

impl LuaTable

Source

pub fn new(i: Index) -> LuaTable

Create a new LuaTable at the given index.

Source

pub fn set_metatable(&self, context: &mut Context<'_>, meta: &LuaTable)

Set this table’s metatable.

Equivalent to the Lua setmetatable function

Source

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

Source

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

Source

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

Source

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

Source

pub fn get_typed<T: FromLua>( &self, context: &mut Context<'_>, key: &dyn ToLua, ) -> Option<T>

Get a value from this table as type T

Source

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

Source

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

Source

pub fn iter_array<F>(&self, context: &mut Context<'_>, func: F)
where F: FnMut(Context<'_>, i64, LuaGeneric),

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

Source

pub fn append(&self, context: &mut Context<'_>, value: &dyn ToLua)

Add an element to the end of the table

Equivalent to the Lua table.insert function

Trait Implementations§

Source§

impl FromLua for LuaTable

Source§

fn from_lua(state: &mut State, index: Index) -> Option<LuaTable>

Converts the value on top of the stack of a Lua state to a value of type Option<Self>.
Source§

impl LuaStackable for LuaTable

Source§

fn get_pos(&self) -> Index

Get the position of this value on the stack
Source§

impl ToLua for LuaTable

Source§

fn to_lua(&self, state: &mut State)

Pushes a value of type Self onto the stack of a Lua state.

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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