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
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for FnCallHashes
impl Debug for FnCallHashes
sourceimpl Default for FnCallHashes
impl Default for FnCallHashes
sourcefn default() -> FnCallHashes
fn default() -> FnCallHashes
Returns the “default value” for a type. Read more
sourceimpl From<u64> for FnCallHashes
impl From<u64> for FnCallHashes
sourceimpl Hash for FnCallHashes
impl Hash for FnCallHashes
sourceimpl PartialEq<FnCallHashes> for FnCallHashes
impl PartialEq<FnCallHashes> for FnCallHashes
sourcefn eq(&self, other: &FnCallHashes) -> bool
fn eq(&self, other: &FnCallHashes) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &FnCallHashes) -> bool
fn ne(&self, other: &FnCallHashes) -> bool
This method tests for !=
.
impl Copy for FnCallHashes
impl Eq for FnCallHashes
impl StructuralEq for FnCallHashes
impl StructuralPartialEq for FnCallHashes
Auto Trait Implementations
impl RefUnwindSafe for FnCallHashes
impl Send for FnCallHashes
impl Sync for FnCallHashes
impl Unpin for FnCallHashes
impl UnwindSafe for FnCallHashes
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CallHasher for T where
T: Hash + ?Sized,
impl<T> CallHasher for T where
T: Hash + ?Sized,
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more