Struct rhai::FnCallHashes[][src]

pub struct FnCallHashes {
    pub script: Option<u64>,
    pub native: u64,
}
Expand description

(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 FnCallHashes[src]

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

Create a FnCallHashes with only the native Rust hash.

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

Create a FnCallHashes 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 FnCallHashes with both native Rust and script function hashes.

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

Is this FnCallHashes native Rust only?

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

Get the script function hash from this FnCallHashes.

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

Get the naive Rust function hash from this FnCallHashes.

Trait Implementations

impl Clone for FnCallHashes[src]

fn clone(&self) -> FnCallHashes[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for FnCallHashes[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Default for FnCallHashes[src]

fn default() -> FnCallHashes[src]

Returns the “default value” for a type. Read more

impl Hash for FnCallHashes[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl PartialEq<FnCallHashes> for FnCallHashes[src]

fn eq(&self, other: &FnCallHashes) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &FnCallHashes) -> bool[src]

This method tests for !=.

impl Copy for FnCallHashes[src]

impl Eq for FnCallHashes[src]

impl StructuralEq for FnCallHashes[src]

impl StructuralPartialEq for FnCallHashes[src]

Auto Trait Implementations

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64 where
    H: Hash + ?Sized,
    B: BuildHasher
[src]

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.