Struct rhai::FnCallHashes
source · pub struct FnCallHashes { /* private fields */ }
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 (if any) 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.
Implementations§
source§impl FnCallHashes
impl FnCallHashes
sourcepub const fn from_hash(hash: u64) -> Self
pub const fn from_hash(hash: u64) -> Self
Create a FnCallHashes
from a single hash.
sourcepub const fn from_native_only(hash: u64) -> Self
pub const fn from_native_only(hash: u64) -> Self
Create a FnCallHashes
with only the native Rust hash.
sourcepub const fn from_script_and_native(script: u64, native: u64) -> Self
pub const fn from_script_and_native(script: u64, native: u64) -> Self
Create a FnCallHashes
with both script function and native Rust hashes.
Not available under no_function
.
sourcepub const fn is_native_only(&self) -> bool
pub const fn is_native_only(&self) -> bool
Is this FnCallHashes
native-only?
sourcepub fn script(&self) -> u64
pub fn script(&self) -> u64
Get the script hash.
The hash returned is never zero.
§Panics
Panics if this FnCallHashes
is native-only.
Trait Implementations§
source§impl Clone for FnCallHashes
impl Clone for FnCallHashes
source§fn clone(&self) -> FnCallHashes
fn clone(&self) -> FnCallHashes
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for FnCallHashes
impl Debug for FnCallHashes
source§impl Hash for FnCallHashes
impl Hash for FnCallHashes
source§impl PartialEq for FnCallHashes
impl PartialEq for FnCallHashes
source§fn eq(&self, other: &FnCallHashes) -> bool
fn eq(&self, other: &FnCallHashes) -> bool
self
and other
values to be equal, and is used
by ==
.impl Copy for FnCallHashes
impl Eq for FnCallHashes
impl StructuralPartialEq for FnCallHashes
Auto Trait Implementations§
impl Freeze for FnCallHashes
impl RefUnwindSafe for FnCallHashes
impl Send for FnCallHashes
impl Sync for FnCallHashes
impl Unpin for FnCallHashes
impl UnwindSafe for FnCallHashes
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> 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>
.