Skip to main content

Exports

Struct Exports 

Source
pub struct Exports { /* private fields */ }
Expand description

The live value returned by a successfully installed script.

Scripts commonly return a table of named functions and data. Use function to retain a callable export, get to copy data into Rust, or get_live to keep a live object. The exports remain usable after another module is installed, but all clones become invalid after Rustia::reset_decision.

Implementations§

Source§

impl Exports

Source

pub fn as_value(&self) -> LiveValue

Clones the underlying live value, whether or not it is a table.

Source

pub fn as_table<C>(&self, rustia: &Rustia<C>) -> Result<Option<Table>>
where C: HostSchema,

Returns a live table handle, or None if the installed script returned another type.

Source

pub fn decision_epoch(&self) -> u64

Returns the decision epoch in which these exports were retained.

Source

pub fn value(&self, rustia: &mut Rustia) -> Result<OwnedValue>

Copies the entire returned value into Rust-owned data.

A returned table containing functions or other values unsupported by OwnedValue cannot be copied as a whole; read individual exports instead.

Source

pub fn value_in<C>( &self, invocation: &mut Invocation<'_, C>, ) -> Result<OwnedValue>
where C: HostSchema,

Copies the returned value within a typed host invocation.

Source

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

Deserializes the returned value without first building an OwnedValue copy.

Source

pub fn get<T>(&self, rustia: &mut Rustia, name: &str) -> Result<T>
where T: FromRustia,

Reads and converts a string-keyed export without invoking __index.

A missing key is nil, so it can be read as Option<T>.

Source

pub fn get_live(&self, rustia: &mut Rustia, name: &str) -> Result<LiveValue>

Reads a string-keyed export as a live value without invoking __index.

Source

pub fn get_in<C, T>( &self, invocation: &mut Invocation<'_, C>, name: &str, ) -> Result<T>
where C: HostSchema, T: FromRustia,

Reads and converts an export within a typed host invocation.

Source

pub fn get_live_in<C>( &self, invocation: &mut Invocation<'_, C>, name: &str, ) -> Result<LiveValue>
where C: HostSchema,

Reads a live export within a typed host invocation.

Source

pub fn function(&self, rustia: &mut Rustia, name: &str) -> Result<Function>

Retains a named function export, or returns an error if it is not a function.

Lookup uses the table’s stored value and does not invoke __index.

Source

pub fn function_in<C>( &self, invocation: &mut Invocation<'_, C>, name: &str, ) -> Result<Function>
where C: HostSchema,

Retains a named function export within a typed host invocation.

Trait Implementations§

Source§

impl Clone for Exports

Source§

fn clone(&self) -> Exports

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 Exports

Source§

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

Formats the value using the given formatter. Read more

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.