pub struct OwnedTable {
pub array: Vec<OwnedValue>,
pub entries: Vec<(OwnedKey, OwnedValue)>,
}Expand description
A Rust-owned table, split into sequence values and keyed entries.
The array field uses zero-based Rust indices, corresponding to Luau
keys 1, 2, and so on. When a script table is copied, a contiguous sequence
becomes array; a sparse or mixed-key table becomes entries.
Fields§
§array: Vec<OwnedValue>Sequence values, starting at Luau index 1.
entries: Vec<(OwnedKey, OwnedValue)>Keyed values in their snapshot order.
Implementations§
Source§impl OwnedTable
impl OwnedTable
Sourcepub fn get_string_deserialized<'de, T>(
&'de self,
key: &str,
) -> Result<Option<T>>where
T: Deserialize<'de>,
pub fn get_string_deserialized<'de, T>(
&'de self,
key: &str,
) -> Result<Option<T>>where
T: Deserialize<'de>,
Deserializes a string-keyed field through serde.
Sourcepub fn get_array_deserialized<'de, T>(
&'de self,
index: usize,
) -> Result<Option<T>>where
T: Deserialize<'de>,
pub fn get_array_deserialized<'de, T>(
&'de self,
index: usize,
) -> Result<Option<T>>where
T: Deserialize<'de>,
Deserializes an owned-array slot by zero-based Rust index. Luau index 1 is slot 0.
Source§impl OwnedTable
impl OwnedTable
Sourcepub fn array(values: impl IntoIterator<Item = OwnedValue>) -> Self
pub fn array(values: impl IntoIterator<Item = OwnedValue>) -> Self
Creates a sequence from values that are already converted.
Sourcepub fn entries(
entries: impl IntoIterator<Item = (OwnedKey, OwnedValue)>,
) -> Self
pub fn entries( entries: impl IntoIterator<Item = (OwnedKey, OwnedValue)>, ) -> Self
Creates a table from keys and values that are already converted.
Sourcepub fn get_string(&self, key: &str) -> Option<&OwnedValue>
pub fn get_string(&self, key: &str) -> Option<&OwnedValue>
Looks up a string key without converting or cloning its value.
Sourcepub fn get_string_table(&self, key: &str) -> Result<Option<&OwnedTable>>
pub fn get_string_table(&self, key: &str) -> Result<Option<&OwnedTable>>
Returns a borrowed table for a string key, or an error if the key holds a non-table value.
Sourcepub fn get_array(&self, index: usize) -> Option<&OwnedValue>
pub fn get_array(&self, index: usize) -> Option<&OwnedValue>
Returns an owned-array slot by zero-based Rust index. Luau index 1 is slot 0.
Sourcepub fn get_array_table(&self, index: usize) -> Result<Option<&OwnedTable>>
pub fn get_array_table(&self, index: usize) -> Result<Option<&OwnedTable>>
Returns a borrowed table for an array slot, or an error if the slot holds a non-table value.
Source§impl OwnedTable
impl OwnedTable
Sourcepub fn array_values<T>(values: impl IntoIterator<Item = T>) -> Result<Self>where
T: IntoRustia,
pub fn array_values<T>(values: impl IntoIterator<Item = T>) -> Result<Self>where
T: IntoRustia,
Converts Rust values into a one-based Luau sequence.
Sourcepub fn string_entries<K, V>(
entries: impl IntoIterator<Item = (K, V)>,
) -> Result<Self>
pub fn string_entries<K, V>( entries: impl IntoIterator<Item = (K, V)>, ) -> Result<Self>
Converts Rust values into a table with string keys.
Sourcepub fn get_string_as<T>(&self, key: &str) -> Result<Option<T>>where
T: FromRustia,
pub fn get_string_as<T>(&self, key: &str) -> Result<Option<T>>where
T: FromRustia,
Reads and converts a string-keyed value. Missing keys return None.
Sourcepub fn get_array_as<T>(&self, index: usize) -> Result<Option<T>>where
T: FromRustia,
pub fn get_array_as<T>(&self, index: usize) -> Result<Option<T>>where
T: FromRustia,
Converts an owned-array slot by zero-based Rust index. Luau index 1 is slot 0.
Trait Implementations§
Source§impl Clone for OwnedTable
impl Clone for OwnedTable
Source§fn clone(&self) -> OwnedTable
fn clone(&self) -> OwnedTable
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more