Struct TableBuilder

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

Utility struct for building Lua tables.

Implementations§

Source§

impl TableBuilder

Source

pub fn new(lua: Lua) -> LuaResult<Self>

Creates a new table builder.

Source

pub fn with_value<K, V>(self, key: K, value: V) -> LuaResult<Self>
where K: IntoLua, V: IntoLua,

Adds a new key-value pair to the table.

This will overwrite any value that already exists.

Source

pub fn with_values<K, V>(self, values: Vec<(K, V)>) -> LuaResult<Self>
where K: IntoLua, V: IntoLua,

Adds multiple key-value pairs to the table.

This will overwrite any values that already exist.

Source

pub fn with_sequential_value<V>(self, value: V) -> LuaResult<Self>
where V: IntoLua,

Adds a new key-value pair to the sequential (array) section of the table.

This will not overwrite any value that already exists, instead adding the value to the end of the array.

Source

pub fn with_sequential_values<V>(self, values: Vec<V>) -> LuaResult<Self>
where V: IntoLua,

Adds multiple values to the sequential (array) section of the table.

This will not overwrite any values that already exist, instead adding the values to the end of the array.

Source

pub fn with_function<K, A, R, F>(self, key: K, func: F) -> LuaResult<Self>
where K: IntoLua, A: FromLuaMulti, R: IntoLuaMulti, F: Fn(&Lua, A) -> LuaResult<R> + 'static,

Adds a new key-value pair to the table, with a function value.

This will overwrite any value that already exists.

Source

pub fn with_async_function<K, A, R, F, FR>( self, key: K, func: F, ) -> LuaResult<Self>
where K: IntoLua, A: FromLuaMulti, R: IntoLuaMulti, F: Fn(Lua, A) -> FR + 'static, FR: Future<Output = LuaResult<R>> + 'static,

Adds a new key-value pair to the table, with an async function value.

This will overwrite any value that already exists.

Source

pub fn with_metatable(self, table: LuaTable) -> LuaResult<Self>

Adds a metatable to the table.

This will overwrite any metatable that already exists.

Source

pub fn build_readonly(self) -> LuaResult<LuaTable>

Builds the table as a read-only table.

This will prevent any direct modifications to the table.

Source

pub fn build(self) -> LuaResult<LuaTable>

Builds the table.

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.
Source§

impl<T> MaybeSend for T