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
impl Exports
Sourcepub fn as_value(&self) -> LiveValue
pub fn as_value(&self) -> LiveValue
Clones the underlying live value, whether or not it is a table.
Sourcepub fn as_table<C>(&self, rustia: &Rustia<C>) -> Result<Option<Table>>where
C: HostSchema,
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.
Sourcepub fn decision_epoch(&self) -> u64
pub fn decision_epoch(&self) -> u64
Returns the decision epoch in which these exports were retained.
Sourcepub fn value(&self, rustia: &mut Rustia) -> Result<OwnedValue>
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.
Sourcepub fn value_in<C>(
&self,
invocation: &mut Invocation<'_, C>,
) -> Result<OwnedValue>where
C: HostSchema,
pub fn value_in<C>(
&self,
invocation: &mut Invocation<'_, C>,
) -> Result<OwnedValue>where
C: HostSchema,
Copies the returned value within a typed host invocation.
Sourcepub fn deserialize<T>(&self, rustia: &mut Rustia<impl HostSchema>) -> Result<T>where
T: DeserializeOwned,
pub fn deserialize<T>(&self, rustia: &mut Rustia<impl HostSchema>) -> Result<T>where
T: DeserializeOwned,
Deserializes the returned value without first building an OwnedValue copy.
Sourcepub fn get<T>(&self, rustia: &mut Rustia, name: &str) -> Result<T>where
T: FromRustia,
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>.
Sourcepub fn get_live(&self, rustia: &mut Rustia, name: &str) -> Result<LiveValue>
pub fn get_live(&self, rustia: &mut Rustia, name: &str) -> Result<LiveValue>
Reads a string-keyed export as a live value without invoking __index.
Sourcepub fn get_in<C, T>(
&self,
invocation: &mut Invocation<'_, C>,
name: &str,
) -> Result<T>where
C: HostSchema,
T: FromRustia,
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.
Sourcepub fn get_live_in<C>(
&self,
invocation: &mut Invocation<'_, C>,
name: &str,
) -> Result<LiveValue>where
C: HostSchema,
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.
Sourcepub fn function(&self, rustia: &mut Rustia, name: &str) -> Result<Function>
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.
Sourcepub fn function_in<C>(
&self,
invocation: &mut Invocation<'_, C>,
name: &str,
) -> Result<Function>where
C: HostSchema,
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.