Struct lune_utils::TableBuilder
source · pub struct TableBuilder<'lua> { /* private fields */ }Expand description
Utility struct for building Lua tables.
Implementations§
source§impl<'lua> TableBuilder<'lua>
impl<'lua> TableBuilder<'lua>
sourcepub fn with_value<K, V>(self, key: K, value: V) -> LuaResult<Self>
pub fn with_value<K, V>(self, key: K, value: V) -> LuaResult<Self>
Adds a new key-value pair to the table.
This will overwrite any value that already exists.
sourcepub fn with_values<K, V>(self, values: Vec<(K, V)>) -> LuaResult<Self>
pub fn with_values<K, V>(self, values: Vec<(K, V)>) -> LuaResult<Self>
Adds multiple key-value pairs to the table.
This will overwrite any values that already exist.
sourcepub fn with_sequential_value<V>(self, value: V) -> LuaResult<Self>where
V: IntoLua<'lua>,
pub fn with_sequential_value<V>(self, value: V) -> LuaResult<Self>where
V: IntoLua<'lua>,
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.
sourcepub fn with_sequential_values<V>(self, values: Vec<V>) -> LuaResult<Self>where
V: IntoLua<'lua>,
pub fn with_sequential_values<V>(self, values: Vec<V>) -> LuaResult<Self>where
V: IntoLua<'lua>,
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.
sourcepub fn with_function<K, A, R, F>(self, key: K, func: F) -> LuaResult<Self>where
K: IntoLua<'lua>,
A: FromLuaMulti<'lua>,
R: IntoLuaMulti<'lua>,
F: Fn(&'lua Lua, A) -> LuaResult<R> + 'static,
pub fn with_function<K, A, R, F>(self, key: K, func: F) -> LuaResult<Self>where
K: IntoLua<'lua>,
A: FromLuaMulti<'lua>,
R: IntoLuaMulti<'lua>,
F: Fn(&'lua 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.
sourcepub fn with_async_function<K, A, R, F, FR>(
self,
key: K,
func: F
) -> LuaResult<Self>where
K: IntoLua<'lua>,
A: FromLuaMulti<'lua>,
R: IntoLuaMulti<'lua>,
F: Fn(&'lua Lua, A) -> FR + 'static,
FR: Future<Output = LuaResult<R>> + 'lua,
pub fn with_async_function<K, A, R, F, FR>(
self,
key: K,
func: F
) -> LuaResult<Self>where
K: IntoLua<'lua>,
A: FromLuaMulti<'lua>,
R: IntoLuaMulti<'lua>,
F: Fn(&'lua Lua, A) -> FR + 'static,
FR: Future<Output = LuaResult<R>> + 'lua,
Adds a new key-value pair to the table, with an async function value.
This will overwrite any value that already exists.
sourcepub fn with_metatable(self, table: LuaTable<'_>) -> LuaResult<Self>
pub fn with_metatable(self, table: LuaTable<'_>) -> LuaResult<Self>
Adds a metatable to the table.
This will overwrite any metatable that already exists.
sourcepub fn build_readonly(self) -> LuaResult<LuaTable<'lua>>
pub fn build_readonly(self) -> LuaResult<LuaTable<'lua>>
Builds the table as a read-only table.
This will prevent any direct modifications to the table.