Skip to main content

OwnedTable

Struct OwnedTable 

Source
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

Source

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.

Source

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

Source

pub fn new() -> Self

Creates an empty table.

Source

pub fn array(values: impl IntoIterator<Item = OwnedValue>) -> Self

Creates a sequence from values that are already converted.

Source

pub fn entries( entries: impl IntoIterator<Item = (OwnedKey, OwnedValue)>, ) -> Self

Creates a table from keys and values that are already converted.

Source

pub fn get_string(&self, key: &str) -> Option<&OwnedValue>

Looks up a string key without converting or cloning its value.

Source

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.

Source

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.

Source

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

Source

pub fn array_values<T>(values: impl IntoIterator<Item = T>) -> Result<Self>
where T: IntoRustia,

Converts Rust values into a one-based Luau sequence.

Source

pub fn string_entries<K, V>( entries: impl IntoIterator<Item = (K, V)>, ) -> Result<Self>
where K: Into<String>, V: IntoRustia,

Converts Rust values into a table with string keys.

Source

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.

Source

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

Source§

fn clone(&self) -> OwnedTable

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OwnedTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for OwnedTable

Source§

fn default() -> OwnedTable

Returns the “default value” for a type. Read more
Source§

impl FromRustia for OwnedTable

Source§

fn from_rustia(value: OwnedValue) -> Result<Self>

Converts a value, returning an error for an incompatible type or range.
Source§

impl FromRustiaMulti for OwnedTable

Source§

fn from_rustia_multi(values: Vec<OwnedValue>) -> Result<Self>

Converts the selected return values.
Source§

impl IntoRustia for OwnedTable

Source§

fn into_rustia(self) -> Result<OwnedValue>

Converts this value, returning an error if it cannot be represented.
Source§

impl IntoRustiaMulti for OwnedTable

Source§

fn into_rustia_multi(self) -> Result<Vec<OwnedValue>>

Converts the complete argument or result list.
Source§

fn rustia_type_names() -> Vec<&'static str>
where Self: Sized,

Returns Rust type names used by host-function signature metadata.
Source§

impl PartialEq for OwnedTable

Source§

fn eq(&self, other: &OwnedTable) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for OwnedTable

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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> FromHostArgument for T
where T: Argument,

Source§

impl<T> IntoHostReturn for T
where T: Return,

Source§

impl<T> IntoHostValue for T
where T: Value,