pub struct Table { /* private fields */ }Expand description
A live table that Rust and Luau can both read and change.
Clones refer to the same table. All lookups and writes are raw: they bypass
__index and __newindex. Like Value, a table belongs to one VM and
becomes invalid after Rustia::reset_decision.
use rustia::Rustia;
let mut lua = Rustia::builder().build()?;
let scores = lua.create_table()?;
scores.set(&mut lua, "Ada", 42)?;
assert_eq!(scores.get(&mut lua, "Ada")?.as_number(&lua)?, Some(42.0));Implementations§
Source§impl Table
impl Table
Sourcepub fn deserialize<T>(&self, rustia: &mut Rustia<impl HostSchema>) -> Result<T>where
T: DeserializeOwned,
pub fn deserialize<T>(&self, rustia: &mut Rustia<impl HostSchema>) -> Result<T>where
T: DeserializeOwned,
Deserializes this table without first building an OwnedValue copy.
Sourcepub const fn decision_epoch(&self) -> u64
pub const fn decision_epoch(&self) -> u64
Returns the decision epoch in which this handle was retained.
Sourcepub fn get_value<C>(&self, rustia: &mut Rustia<C>, key: &Value) -> Result<Value>where
C: HostSchema,
pub fn get_value<C>(&self, rustia: &mut Rustia<C>, key: &Value) -> Result<Value>where
C: HostSchema,
Looks up a live key without invoking __index. Missing keys return nil.
Sourcepub fn get<K, C>(&self, rustia: &mut Rustia<C>, key: K) -> Result<Value>where
K: IntoRustia,
C: HostSchema,
pub fn get<K, C>(&self, rustia: &mut Rustia<C>, key: K) -> Result<Value>where
K: IntoRustia,
C: HostSchema,
Looks up a Rust key without invoking __index. Missing keys return nil.
Sourcepub fn set_value<C>(
&self,
rustia: &mut Rustia<C>,
key: &Value,
value: &Value,
) -> Result<()>where
C: HostSchema,
pub fn set_value<C>(
&self,
rustia: &mut Rustia<C>,
key: &Value,
value: &Value,
) -> Result<()>where
C: HostSchema,
Performs a raw write with live key/value handles, bypassing __newindex.
Sourcepub fn set_live<K, C>(
&self,
rustia: &mut Rustia<C>,
key: K,
value: &Value,
) -> Result<()>where
K: IntoRustia,
C: HostSchema,
pub fn set_live<K, C>(
&self,
rustia: &mut Rustia<C>,
key: K,
value: &Value,
) -> Result<()>where
K: IntoRustia,
C: HostSchema,
Stores a live value under a Rust key without invoking __newindex.
The stored value keeps its identity; it is not copied into a new object.
Sourcepub fn set<K, V, C>(
&self,
rustia: &mut Rustia<C>,
key: K,
value: V,
) -> Result<()>
pub fn set<K, V, C>( &self, rustia: &mut Rustia<C>, key: K, value: V, ) -> Result<()>
Converts and stores a Rust key and value without invoking __newindex.
Use set_live to store an existing script object.
Sourcepub fn entries<C>(&self, rustia: &mut Rustia<C>) -> Result<Vec<(Value, Value)>>where
C: HostSchema,
pub fn entries<C>(&self, rustia: &mut Rustia<C>) -> Result<Vec<(Value, Value)>>where
C: HostSchema,
Returns the current entries in insertion order as live key/value handles.
Mutating the table later does not change which key/value handles this returned vector contains, though those handles still refer to their original live objects.