Skip to main content

OwnedValue

Enum OwnedValue 

Source
pub enum OwnedValue {
    Nil,
    Boolean(bool),
    Number(f64),
    String(String),
    Table(OwnedTable),
}
Expand description

A Rust-owned copy of a script value.

Use this for ordinary data that should outlive the VM or a reset_decision. Tables are copied recursively; changes to the original script table do not affect the copy.

This representation supports UTF-8 strings and acyclic tables with boolean, number, or string keys. Use a live crate::Value for binary strings, functions, buffers, vectors, userdata, or shared and cyclic table identity.

Variants§

§

Nil

§

Boolean(bool)

§

Number(f64)

§

String(String)

§

Table(OwnedTable)

Implementations§

Source§

impl OwnedValue

Source

pub fn deserialize<'de, T>(&'de self) -> Result<T>
where T: Deserialize<'de>,

Reads this value as a Serde-compatible Rust type.

The result may borrow from this owned value. For example, a script string can be read as &str without making another copy. Conversion failures include a field path in Error::diagnostic when available.

Source

pub fn from_serialize<T>(value: &T) -> Result<Self>
where T: Serialize + ?Sized,

Copies Serde-compatible Rust data into a value independent of any VM.

To send data straight to a script global, use Rustia::insert_serde.

Source§

impl OwnedValue

Source

pub fn type_name(&self) -> &'static str

Returns the corresponding Luau type name.

Source

pub fn table(&self) -> Option<&OwnedTable>

Borrows the table contents, or returns None for another value kind.

Trait Implementations§

Source§

impl Clone for OwnedValue

Source§

fn clone(&self) -> OwnedValue

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 OwnedValue

Source§

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

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

impl FromRustia for OwnedValue

Source§

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

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

impl FromRustiaMulti for OwnedValue

Source§

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

Converts the selected return values.
Source§

impl IntoRustia for OwnedValue

Source§

fn into_rustia(self) -> Result<OwnedValue>

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

impl IntoRustiaMulti for OwnedValue

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 OwnedValue

Source§

fn eq(&self, other: &OwnedValue) -> 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 OwnedValue

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,