Trait rhai::RhaiNativeFunc
source · pub trait RhaiNativeFunc<A: 'static, const N: usize, const X: bool, R: 'static, const F: bool> {
// Required methods
fn into_rhai_function(self, is_pure: bool, is_volatile: bool) -> RhaiFunc;
fn param_types() -> [TypeId; N];
fn param_names() -> [&'static str; N];
// Provided methods
fn num_params() -> usize { ... }
fn has_context() -> bool { ... }
fn return_type() -> TypeId { ... }
fn return_type_name() -> &'static str { ... }
}
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§
sourcefn 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
.
sourcefn param_types() -> [TypeId; N]
fn param_types() -> [TypeId; N]
Get the type ID’s of this function’s parameters.
sourcefn param_names() -> [&'static str; N]
fn param_names() -> [&'static str; N]
(metadata) Get the type names of this function’s parameters.
Exported under the metadata
feature only.
Provided Methods§
sourcefn num_params() -> usize
fn num_params() -> usize
Get the number of parameters for this function.
sourcefn has_context() -> bool
fn has_context() -> bool
Is there a NativeCallContext
parameter for this function?
sourcefn return_type() -> TypeId
fn return_type() -> TypeId
(metadata) Get the type ID of this function’s return value.
Exported under the metadata
feature only.
sourcefn return_type_name() -> &'static str
fn return_type_name() -> &'static str
(metadata) Get the type name of this function’s return value.
Exported under the metadata
feature only.
Object Safety§
This trait is not object safe.