Struct rhai::FnCallHashes
source · [−]Expand description
(internals) A set of function call hashes. Exported under the internals
feature only.
Two separate hashes are pre-calculated because of the following patterns:
func(a, b, c); // Native: func(a, b, c) - 3 parameters
// Script: func(a, b, c) - 3 parameters
a.func(b, c); // Native: func(&mut a, b, c) - 3 parameters
// Script: func(b, c) - 2 parameters
For normal function calls, the native hash equals the script hash.
For method-style calls, the script hash contains one fewer parameter.
Function call hashes are used in the following manner:
-
First, the script hash is tried, which contains only the called function’s name plus the number of parameters.
-
Next, the actual types of arguments are hashed and combined with the native hash, which is then used to search for a native function. In other words, a complete native function call hash always contains the called function’s name plus the types of the arguments. This is due to possible function overloading for different parameter types.
Fields
script: u64
Pre-calculated hash for a script-defined function (zero if native functions only).
native: u64
Pre-calculated hash for a native Rust function with no parameter types.
Implementations
sourceimpl FnCallHashes
impl FnCallHashes
sourcepub const fn from_native(hash: u64) -> Self
pub const fn from_native(hash: u64) -> Self
Create a FnCallHashes
with only the native Rust hash.
sourcepub const fn from_all(script: u64, native: u64) -> Self
pub const fn from_all(script: u64, native: u64) -> Self
Create a FnCallHashes
with both native Rust and script function hashes.
sourcepub const fn is_native_only(&self) -> bool
pub const fn is_native_only(&self) -> bool
Is this FnCallHashes
native Rust only?
Trait Implementations
sourceimpl Clone for FnCallHashes
impl Clone for FnCallHashes
sourcefn clone(&self) -> FnCallHashes
fn clone(&self) -> FnCallHashes
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more