Struct rhai::FnCallHash[][src]

pub struct FnCallHash {
    pub script: Option<u64>,
    pub native: u64,
}

(INTERNALS) An set of function call hashes. Exported under the internals feature only.

Two separate hashes are pre-calculated because of the following pattern:

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 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 native function call hash always contains the called function’s name plus the types of the arguments. This is to due to possible function overloading for different parameter types.

Volatile Data Structure

This type is volatile and may change.

Fields

script: Option<u64>

Pre-calculated hash for a script-defined function (None if native functions only).

native: u64

Pre-calculated hash for a native Rust function with no parameter types.

Implementations

impl FnCallHash[src]

pub fn from_native(hash: u64) -> Self[src]

Create a FnCallHash with only the native Rust hash.

pub fn from_script(hash: u64) -> Self[src]

Create a FnCallHash with both native Rust and script function hashes set to the same value.

pub fn from_script_and_native(script: u64, native: u64) -> Self[src]

Create a FnCallHash with both native Rust and script function hashes.

pub fn is_native_only(&self) -> bool[src]

Is this FnCallHash native Rust only?

pub fn script_hash(&self) -> u64[src]

Get the script function hash from this FnCallHash.

Panics

Panics if the FnCallHash is native Rust only.

pub fn native_hash(&self) -> u64[src]

Get the naive Rust function hash from this FnCallHash.

Trait Implementations

impl Clone for FnCallHash[src]

impl Copy for FnCallHash[src]

impl Debug for FnCallHash[src]

impl Default for FnCallHash[src]

impl Eq for FnCallHash[src]

impl Hash for FnCallHash[src]

impl PartialEq<FnCallHash> for FnCallHash[src]

impl StructuralEq for FnCallHash[src]

impl StructuralPartialEq for FnCallHash[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CallHasher for T where
    T: Hash + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.