#[non_exhaustive]pub enum RhaiFunc {
Pure {
func: Shared<dyn Fn(Option<NativeCallContext<'_>>, &mut [&'_ mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>>>,
has_context: bool,
is_pure: bool,
is_volatile: bool,
},
Method {
func: Shared<dyn Fn(Option<NativeCallContext<'_>>, &mut [&'_ mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>>>,
has_context: bool,
is_pure: bool,
is_volatile: bool,
},
Iterator {
func: Shared<dyn Fn(Dynamic) -> Box<dyn Iterator<Item = Result<Dynamic, Box<EvalAltResult>>>>>,
},
Plugin {
func: Shared<dyn PluginFunc>,
},
Script {
fn_def: Shared<ScriptFuncDef>,
env: 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
A pure native Rust function with all arguments passed by value.
Fields
func: Shared<dyn Fn(Option<NativeCallContext<'_>>, &mut [&'_ mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>>>Shared function pointer.
has_context: boolDoes the function take a NativeCallContext parameter?
Method
A native Rust object method with the first argument passed by reference, and the rest passed by value.
Fields
func: Shared<dyn Fn(Option<NativeCallContext<'_>>, &mut [&'_ mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>>>Shared function pointer.
has_context: boolDoes the function take a NativeCallContext parameter?
Iterator
An iterator function.
Fields
Plugin
A plugin function,
Fields
func: Shared<dyn PluginFunc>Shared function pointer.
Script
A script-defined function.
Implementations§
Source§impl RhaiFunc
impl RhaiFunc
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 is_volatile(&self) -> bool
pub fn is_volatile(&self) -> bool
Is this function volatile?
A volatile function does not guarantee the same result for the same input(s).
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<ScriptFuncDef>>
pub const fn get_script_fn_def(&self) -> Option<&Shared<ScriptFuncDef>>
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 encapsulated environment of the function definition (if any).
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 PluginFunc>>
pub fn get_plugin_fn(&self) -> Option<&Shared<dyn PluginFunc>>
Get a shared reference to a plugin function.