Enum rhai::plugin::CallableFunction
source · #[non_exhaustive]pub enum CallableFunction {
Pure {
func: Shared<dyn Fn(Option<NativeCallContext<'_>>, &mut [&'_ mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>>>,
has_context: bool,
is_pure: bool,
},
Method {
func: Shared<dyn Fn(Option<NativeCallContext<'_>>, &mut [&'_ mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>>>,
has_context: bool,
is_pure: bool,
},
Iterator {
func: Shared<dyn Fn(Dynamic) -> Box<dyn Iterator<Item = Result<Dynamic, Box<EvalAltResult>>>>>,
},
Plugin {
func: Shared<dyn PluginFunction>,
},
Script {
fn_def: Shared<ScriptFnDef>,
environ: Option<Shared<EncapsulatedEnviron>>,
},
}
Expand description
(internals) A type encapsulating a function callable by Rhai.
Exported under the internals
feature only.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Pure
Fields
func: Shared<dyn Fn(Option<NativeCallContext<'_>>, &mut [&'_ mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>>>
Shared function pointer.
has_context: bool
Does the function take a NativeCallContext
parameter?
A pure native Rust function with all arguments passed by value.
Method
Fields
func: Shared<dyn Fn(Option<NativeCallContext<'_>>, &mut [&'_ mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>>>
Shared function pointer.
has_context: bool
Does the function take a NativeCallContext
parameter?
A native Rust object method with the first argument passed by reference, and the rest passed by value.
Iterator
Fields
An iterator function.
Plugin
Fields
func: Shared<dyn PluginFunction>
Shared function pointer.
A plugin function,
Script
Fields
fn_def: Shared<ScriptFnDef>
Shared reference to the ScriptFnDef
function definition.
environ: Option<Shared<EncapsulatedEnviron>>
Encapsulated environment, if any.
A script-defined function.
Implementations§
source§impl CallableFunction
impl CallableFunction
sourcepub const fn is_plugin_fn(&self) -> bool
pub const fn is_plugin_fn(&self) -> bool
Is this a plugin function?
sourcepub fn has_context(&self) -> bool
pub fn has_context(&self) -> bool
Is there a NativeCallContext
parameter?
sourcepub fn get_native_fn(
&self
) -> Option<&Shared<dyn Fn(Option<NativeCallContext<'_>>, &mut [&'_ mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>>>>
pub fn get_native_fn( &self ) -> Option<&Shared<dyn Fn(Option<NativeCallContext<'_>>, &mut [&'_ mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>>>>
Get a shared reference to a native Rust function.
sourcepub const fn get_script_fn_def(&self) -> Option<&Shared<ScriptFnDef>>
pub const fn get_script_fn_def(&self) -> Option<&Shared<ScriptFnDef>>
Get a shared reference to a script-defined function definition.
Not available under no_function
.
sourcepub fn get_encapsulated_environ(&self) -> Option<&EncapsulatedEnviron>
pub fn get_encapsulated_environ(&self) -> Option<&EncapsulatedEnviron>
Get a reference to the shared encapsulated environment of the function definition.
Not available under no_function
or no_module
.
sourcepub fn get_iter_fn(
&self
) -> Option<&dyn Fn(Dynamic) -> Box<dyn Iterator<Item = Result<Dynamic, Box<EvalAltResult>>>>>
pub fn get_iter_fn( &self ) -> Option<&dyn Fn(Dynamic) -> Box<dyn Iterator<Item = Result<Dynamic, Box<EvalAltResult>>>>>
Get a reference to an iterator function.
sourcepub fn get_plugin_fn(&self) -> Option<&Shared<dyn PluginFunction>>
pub fn get_plugin_fn(&self) -> Option<&Shared<dyn PluginFunction>>
Get a shared reference to a plugin function.
Trait Implementations§
source§impl Clone for CallableFunction
impl Clone for CallableFunction
source§fn clone(&self) -> CallableFunction
fn clone(&self) -> CallableFunction
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more