pub struct TableBuilder { /* private fields */ }
Expand description
Utility struct for building Lua tables.
Implementations§
Source§impl TableBuilder
impl TableBuilder
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,
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.
Sourcepub fn with_sequential_values<V>(self, values: Vec<V>) -> LuaResult<Self>where
V: IntoLua,
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.
Sourcepub fn with_function<K, A, R, F>(self, key: K, func: F) -> LuaResult<Self>
pub fn with_function<K, A, R, F>(self, key: K, func: F) -> LuaResult<Self>
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,
A: FromLuaMulti,
R: IntoLuaMulti,
F: Fn(Lua, A) -> FR + 'static,
FR: Future<Output = LuaResult<R>> + 'static,
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.
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>
pub fn build_readonly(self) -> LuaResult<LuaTable>
Builds the table as a read-only table.
This will prevent any direct modifications to the table.
Auto Trait Implementations§
impl Freeze for TableBuilder
impl !RefUnwindSafe for TableBuilder
impl !Send for TableBuilder
impl !Sync for TableBuilder
impl Unpin for TableBuilder
impl !UnwindSafe for TableBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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