Skip to main content

Table

Struct Table 

Source
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

Source

pub fn as_value(&self) -> Value

Clones this table’s underlying live value handle.

Source

pub fn deserialize<T>(&self, rustia: &mut Rustia<impl HostSchema>) -> Result<T>

Deserializes this table without first building an OwnedValue copy.

Source

pub const fn decision_epoch(&self) -> u64

Returns the decision epoch in which this handle was retained.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn set<K, V, C>( &self, rustia: &mut Rustia<C>, key: K, value: V, ) -> Result<()>
where K: IntoRustia, V: IntoRustia, C: HostSchema,

Converts and stores a Rust key and value without invoking __newindex.

Use set_live to store an existing script object.

Source

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.

Trait Implementations§

Source§

impl Clone for Table

Source§

fn clone(&self) -> Table

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 Table

Source§

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

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

impl From<&Table> for Table

Source§

fn from(table: &Table) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Table

§

impl !RefUnwindSafe for Table

§

impl !Send for Table

§

impl !Sync for Table

§

impl Unpin for Table

§

impl UnsafeUnpin for Table

§

impl !UnwindSafe for Table

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,