#[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>,
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 PluginFunc>
Shared function pointer.
A plugin function,
Script
Fields
fn_def: Shared<ScriptFuncDef>
Shared reference to the ScriptFuncDef
function definition.
environ: Option<Shared<EncapsulatedEnviron>>
Encapsulated environment, if any.
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 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 PluginFunc>>
pub fn get_plugin_fn(&self) -> Option<&Shared<dyn PluginFunc>>
Get a shared reference to a plugin function.
Trait Implementations§
source§impl From<Rc<ScriptFuncDef>> for RhaiFunc
impl From<Rc<ScriptFuncDef>> for RhaiFunc
source§fn from(fn_def: Shared<ScriptFuncDef>) -> Self
fn from(fn_def: Shared<ScriptFuncDef>) -> Self
source§impl From<Rc<dyn PluginFunc>> for RhaiFunc
impl From<Rc<dyn PluginFunc>> for RhaiFunc
source§fn from(func: Shared<dyn PluginFunc>) -> Self
fn from(func: Shared<dyn PluginFunc>) -> Self
source§impl From<ScriptFuncDef> for RhaiFunc
impl From<ScriptFuncDef> for RhaiFunc
source§fn from(fn_def: ScriptFuncDef) -> Self
fn from(fn_def: ScriptFuncDef) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for RhaiFunc
impl !Send for RhaiFunc
impl !Sync for RhaiFunc
impl Unpin for RhaiFunc
impl !UnwindSafe for RhaiFunc
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Variant for T
impl<T> Variant for T
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Variant
trait object to &mut dyn Any
.source§fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
Variant
trait object to Box<dyn Any>
.