#[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
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: bool
Does 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: bool
Does 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.
Fields
fn_def: Shared<ScriptFuncDef>
Shared reference to the ScriptFuncDef
function definition.
environ: Option<Shared<EncapsulatedEnviron>>
Encapsulated environment, if any.
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 Freeze for RhaiFunc
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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>
.