Trait RhaiNativeFunc
pub trait RhaiNativeFunc<A, const N: usize, const X: bool, R, const F: bool>where
A: 'static,
R: 'static,{
// Required methods
fn into_rhai_function(self, is_pure: bool, is_volatile: bool) -> RhaiFunc;
fn param_types() -> [TypeId; N];
// Provided methods
fn num_params() -> usize { ... }
fn has_context() -> bool { ... }
}
Expand description
Trait to register custom Rust functions.
§Type Parameters
A
- a tuple containing parameter types, with&mut T
represented byMut<T>
.N
- a constant generic containing the number of parameters, must be consistent withARGS
.X
- a constant boolean generic indicating whether there is aNativeCallContext
parameter.R
- return type of the function; if the function returnsResult
, it is the unwrapped inner value type.F
- a constant boolean generic indicating whether the function is fallible (i.e. returnsResult<T, Box<EvalAltResult>>
).
Required Methods§
fn into_rhai_function(self, is_pure: bool, is_volatile: bool) -> RhaiFunc
fn into_rhai_function(self, is_pure: bool, is_volatile: bool) -> RhaiFunc
Convert this function into a RhaiFunc
.
fn param_types() -> [TypeId; N]
fn param_types() -> [TypeId; N]
Get the type ID’s of this function’s parameters.
Provided Methods§
fn num_params() -> usize
fn num_params() -> usize
Get the number of parameters for this function.
fn has_context() -> bool
fn has_context() -> bool
Is there a NativeCallContext
parameter for this function?
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.