Struct rhai::Engine [] [src]

pub struct Engine {
    pub fns: HashMap<String, Vec<FnType>>,
}

Rhai's engine type. This is what you use to run Rhai scripts

extern crate rhai;
use rhai::Engine;
 
fn main() {
    let mut engine = Engine::new();
 
    if let Ok(result) = engine.eval::<i64>("40 + 2") {
        println!("Answer: {}", result);  // prints 42
    }
}

Fields

A hashmap containing all functions know to the engine

Methods

impl Engine
[src]

[src]

Universal method for calling functions, that are either registered with the Engine or written in Rhai

[src]

Register a type for use with Engine. Keep in mind that your type must implement Clone.

[src]

Register a get function for a member of a registered type

[src]

Register a set function for a member of a registered type

[src]

Shorthand for registering both getters and setters

[src]

Evaluate a file

[src]

Evaluate a string

[src]

Evaluate with own scope

[src]

Evaluate a file, but only return errors, if there are any. Useful for when you don't need the result, but still need to keep track of possible errors

[src]

Evaluate a string, but only return errors, if there are any. Useful for when you don't need the result, but still need to keep track of possible errors

[src]

Evaluate a string with own scoppe, but only return errors, if there are any. Useful for when you don't need the result, but still need to keep track of possible errors

[src]

Register the default library. That means, numberic types, char, bool String, arithmetics and string concatenations.

[src]

Make a new engine

Trait Implementations

impl<'a, A, T, U, V, W, X, Y, Z> FnRegister<A, Z, (&'a mut T, U, V, W, X, Y)> for Engine where
    A: 'static + Fn(&mut T, U, V, W, X, Y) -> Z,
    T: Any,
    U: Clone + Any,
    V: Clone + Any,
    W: Clone + Any,
    X: Clone + Any,
    Y: Clone + Any,
    Z: Any
[src]

[src]

A method used for registering functions and methods to a Engine

impl<'a, A, T, U, V, W, X, Y, Z> FnRegister<A, Z, (&'a T, U, V, W, X, Y)> for Engine where
    A: 'static + Fn(T, U, V, W, X, Y) -> Z,
    T: Clone + Any,
    U: Clone + Any,
    V: Clone + Any,
    W: Clone + Any,
    X: Clone + Any,
    Y: Clone + Any,
    Z: Any
[src]

[src]

A method used for registering functions and methods to a Engine

impl<'a, A, T, U, V, W, X, Y> FnRegister<A, Y, (&'a mut T, U, V, W, X)> for Engine where
    A: 'static + Fn(&mut T, U, V, W, X) -> Y,
    T: Any,
    U: Clone + Any,
    V: Clone + Any,
    W: Clone + Any,
    X: Clone + Any,
    Y: Any
[src]

[src]

A method used for registering functions and methods to a Engine

impl<'a, A, T, U, V, W, X, Y> FnRegister<A, Y, (&'a T, U, V, W, X)> for Engine where
    A: 'static + Fn(T, U, V, W, X) -> Y,
    T: Clone + Any,
    U: Clone + Any,
    V: Clone + Any,
    W: Clone + Any,
    X: Clone + Any,
    Y: Any
[src]

[src]

A method used for registering functions and methods to a Engine

impl<'a, A, T, U, V, W, X> FnRegister<A, X, (&'a mut T, U, V, W)> for Engine where
    A: 'static + Fn(&mut T, U, V, W) -> X,
    T: Any,
    U: Clone + Any,
    V: Clone + Any,
    W: Clone + Any,
    X: Any
[src]

[src]

A method used for registering functions and methods to a Engine

impl<'a, A, T, U, V, W, X> FnRegister<A, X, (&'a T, U, V, W)> for Engine where
    A: 'static + Fn(T, U, V, W) -> X,
    T: Clone + Any,
    U: Clone + Any,
    V: Clone + Any,
    W: Clone + Any,
    X: Any
[src]

[src]

A method used for registering functions and methods to a Engine

impl<'a, A, T, U, V, W> FnRegister<A, W, (&'a mut T, U, V)> for Engine where
    A: 'static + Fn(&mut T, U, V) -> W,
    T: Any,
    U: Clone + Any,
    V: Clone + Any,
    W: Any
[src]

[src]

A method used for registering functions and methods to a Engine

impl<'a, A, T, U, V, W> FnRegister<A, W, (&'a T, U, V)> for Engine where
    A: 'static + Fn(T, U, V) -> W,
    T: Clone + Any,
    U: Clone + Any,
    V: Clone + Any,
    W: Any
[src]

[src]

A method used for registering functions and methods to a Engine

impl<'a, A, T, U, V> FnRegister<A, V, (&'a mut T, U)> for Engine where
    A: 'static + Fn(&mut T, U) -> V,
    T: Any,
    U: Clone + Any,
    V: Any
[src]

[src]

A method used for registering functions and methods to a Engine

impl<'a, A, T, U, V> FnRegister<A, V, (&'a T, U)> for Engine where
    A: 'static + Fn(T, U) -> V,
    T: Clone + Any,
    U: Clone + Any,
    V: Any
[src]

[src]

A method used for registering functions and methods to a Engine

impl<'a, A, T, U> FnRegister<A, U, &'a mut T> for Engine where
    A: 'static + Fn(&mut T) -> U,
    T: Any,
    U: Any
[src]

[src]

A method used for registering functions and methods to a Engine

impl<'a, A, T, U> FnRegister<A, U, &'a T> for Engine where
    A: 'static + Fn(T) -> U,
    T: Clone + Any,
    U: Any
[src]

[src]

A method used for registering functions and methods to a Engine

impl<A, T> FnRegister<A, T, ()> for Engine where
    A: 'static + Fn() -> T,
    T: Any
[src]

[src]

A method used for registering functions and methods to a Engine