pub struct Script { /* private fields */ }Expand description
A loaded script. Send + Sync: one instance serves every thread, and a
call takes &self.
Implementations§
Source§impl Script
impl Script
Sourcepub fn load(path: impl AsRef<Path>) -> Result<Script, Error>
pub fn load(path: impl AsRef<Path>) -> Result<Script, Error>
Load a file with no grants. Hermetic: the load fails if the script could read anything at all.
pub fn builder() -> ScriptBuilder
Sourcepub fn version(&self) -> ScriptVersion
pub fn version(&self) -> ScriptVersion
The version serving now.
Sourcepub fn reload(&self) -> Result<ScriptVersion, Error>
pub fn reload(&self) -> Result<ScriptVersion, Error>
Read the script’s files again and, if they changed, load them as a new version (D36). The new version passes every check the first load did, with the same grants, against the same lock, and keeps every export the host may have bound; if anything fails, the old version keeps serving and the error says why. Content decides: files rewritten with the same bytes are not a new version.
Sourcepub fn output<T: DeserializeOwned>(&self) -> Result<T, Error>
pub fn output<T: DeserializeOwned>(&self) -> Result<T, Error>
The whole manifest, as aura eval prints it - properties and blocks,
not bindings, functions, schemas or enums - as any Deserialize type.
Sourcepub fn get<T: DeserializeOwned>(&self, name: &str) -> Result<T, Error>
pub fn get<T: DeserializeOwned>(&self, name: &str) -> Result<T, Error>
A value the script exports, as any Deserialize type.
Sourcepub fn call<A: Args, R: DeserializeOwned>(
&self,
name: &str,
args: A,
) -> Result<R, Error>
pub fn call<A: Args, R: DeserializeOwned>( &self, name: &str, args: A, ) -> Result<R, Error>
Call a function by name. For a function called often, bind it once with
Script::function instead: the lookup and the checks then happen once.
Sourcepub fn function<A: Args, R: DeserializeOwned>(
&self,
name: &str,
) -> Result<Function<'_, A, R>, Error>
pub fn function<A: Args, R: DeserializeOwned>( &self, name: &str, ) -> Result<Function<'_, A, R>, Error>
Bind a function, checking now - not on the first request - that the name
exists (E0002), names a function (E0003), and takes as many
arguments as A has (E0004). A reload keeps all three true (D36 §2).