Enum rhai::plugin::CallableFunction[][src]

pub enum CallableFunction {
    Pure(Rc<dyn Fn(&Engine, &Module, &mut [&'_ mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>>>),
    Method(Rc<dyn Fn(&Engine, &Module, &mut [&'_ mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>>>),
    Iterator(fn(_: Dynamic) -> Box<dyn Iterator<Item = Dynamic>>),
    Plugin(Rc<dyn PluginFunction>),
    Script(Rc<ScriptFnDef>),
}
Expand description

A type encapsulating a function callable by Rhai.

Variants

Pure(Rc<dyn Fn(&Engine, &Module, &mut [&'_ mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>>>)

Tuple Fields

A pure native Rust function with all arguments passed by value.

Method(Rc<dyn Fn(&Engine, &Module, &mut [&'_ mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>>>)

Tuple Fields

A native Rust object method with the first argument passed by reference, and the rest passed by value.

Iterator(fn(_: Dynamic) -> Box<dyn Iterator<Item = Dynamic>>)

Tuple Fields

0: fn(_: Dynamic) -> Box<dyn Iterator<Item = Dynamic>>

An iterator function.

Plugin(Rc<dyn PluginFunction>)

Tuple Fields

A plugin function,

Script(Rc<ScriptFnDef>)

Tuple Fields

A script-defined function.

Implementations

Is this a pure native Rust function?

Is this a native Rust method function?

Is this an iterator function?

Is this a Rhai-scripted function?

Is this a plugin function?

Is this a native Rust function?

Get the access mode.

Get a reference to a native Rust function.

Panics

Panics if the CallableFunction is not Pure or Method.

Get a shared reference to a script-defined function definition.

Panics

Panics if the CallableFunction is not Script.

Get a reference to a script-defined function definition.

Panics

Panics if the CallableFunction is not Script.

Get a reference to an iterator function.

Panics

Panics if the CallableFunction is not Iterator.

Get a reference to a plugin function.

Panics

Panics if the CallableFunction is not Plugin.

Create a new CallableFunction::Pure.

Create a new CallableFunction::Method.

Create a new CallableFunction::Plugin.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.