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
fns: HashMap<String, Vec<FnType>>
A hashmap containing all functions know to the engine
Methods
impl Engine
[src]
fn call_fn(
&self,
name: &str,
arg1: Option<&mut Box<Any>>,
arg2: Option<&mut Box<Any>>,
arg3: Option<&mut Box<Any>>,
arg4: Option<&mut Box<Any>>,
arg5: Option<&mut Box<Any>>,
arg6: Option<&mut Box<Any>>
) -> Result<Box<Any>, EvalAltResult>
[src]
&self,
name: &str,
arg1: Option<&mut Box<Any>>,
arg2: Option<&mut Box<Any>>,
arg3: Option<&mut Box<Any>>,
arg4: Option<&mut Box<Any>>,
arg5: Option<&mut Box<Any>>,
arg6: Option<&mut Box<Any>>
) -> Result<Box<Any>, EvalAltResult>
Universal method for calling functions, that are either
registered with the Engine
or written in Rhai
fn register_type<T: Clone + Any>(&mut self)
[src]
Register a type for use with Engine. Keep in mind that your type must implement Clone.
fn register_get<T: Clone + Any, U: Clone + Any, F>(
&mut self,
name: &str,
get_fn: F
) where
F: 'static + Fn(&mut T) -> U,
[src]
&mut self,
name: &str,
get_fn: F
) where
F: 'static + Fn(&mut T) -> U,
Register a get function for a member of a registered type
fn register_set<T: Clone + Any, U: Clone + Any, F>(
&mut self,
name: &str,
set_fn: F
) where
F: 'static + Fn(&mut T, U),
[src]
&mut self,
name: &str,
set_fn: F
) where
F: 'static + Fn(&mut T, U),
Register a set function for a member of a registered type
fn register_get_set<T: Clone + Any, U: Clone + Any, F, G>(
&mut self,
name: &str,
get_fn: F,
set_fn: G
) where
F: 'static + Fn(&mut T) -> U,
G: 'static + Fn(&mut T, U),
[src]
&mut self,
name: &str,
get_fn: F,
set_fn: G
) where
F: 'static + Fn(&mut T) -> U,
G: 'static + Fn(&mut T, U),
Shorthand for registering both getters and setters
fn eval_file<T: Any + Clone>(&mut self, fname: &str) -> Result<T, EvalAltResult>
[src]
Evaluate a file
fn eval<T: Any + Clone>(&mut self, input: &str) -> Result<T, EvalAltResult>
[src]
Evaluate a string
fn eval_with_scope<T: Any + Clone>(
&mut self,
scope: &mut Scope,
input: &str
) -> Result<T, EvalAltResult>
[src]
&mut self,
scope: &mut Scope,
input: &str
) -> Result<T, EvalAltResult>
Evaluate with own scope
fn consume_file(&mut self, fname: &str) -> Result<(), EvalAltResult>
[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
fn consume(&mut self, input: &str) -> Result<(), EvalAltResult>
[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
fn consume_with_scope(
&mut self,
scope: &mut Scope,
input: &str
) -> Result<(), EvalAltResult>
[src]
&mut self,
scope: &mut Scope,
input: &str
) -> Result<(), EvalAltResult>
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
fn register_default_lib(engine: &mut Engine)
[src]
Register the default library. That means, numberic types, char, bool String, arithmetics and string concatenations.
fn new() -> Engine
[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]
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,
fn register_fn(&mut self, name: &str, fun: A)
[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]
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,
fn register_fn(&mut self, name: &str, fun: A)
[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]
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,
fn register_fn(&mut self, name: &str, fun: A)
[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]
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,
fn register_fn(&mut self, name: &str, fun: A)
[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]
A: 'static + Fn(&mut T, U, V, W) -> X,
T: Any,
U: Clone + Any,
V: Clone + Any,
W: Clone + Any,
X: Any,
fn register_fn(&mut self, name: &str, fun: A)
[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]
A: 'static + Fn(T, U, V, W) -> X,
T: Clone + Any,
U: Clone + Any,
V: Clone + Any,
W: Clone + Any,
X: Any,
fn register_fn(&mut self, name: &str, fun: A)
[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]
A: 'static + Fn(&mut T, U, V) -> W,
T: Any,
U: Clone + Any,
V: Clone + Any,
W: Any,
fn register_fn(&mut self, name: &str, fun: A)
[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]
A: 'static + Fn(T, U, V) -> W,
T: Clone + Any,
U: Clone + Any,
V: Clone + Any,
W: Any,
fn register_fn(&mut self, name: &str, fun: A)
[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]
A: 'static + Fn(&mut T, U) -> V,
T: Any,
U: Clone + Any,
V: Any,
fn register_fn(&mut self, name: &str, fun: A)
[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]
A: 'static + Fn(T, U) -> V,
T: Clone + Any,
U: Clone + Any,
V: Any,
fn register_fn(&mut self, name: &str, fun: A)
[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]
A: 'static + Fn(&mut T) -> U,
T: Any,
U: Any,
fn register_fn(&mut self, name: &str, fun: A)
[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]
A: 'static + Fn(T) -> U,
T: Clone + Any,
U: Any,
fn register_fn(&mut self, name: &str, fun: A)
[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]
A: 'static + Fn() -> T,
T: Any,
fn register_fn(&mut self, name: &str, fun: A)
[src]
A method used for registering functions and methods to a Engine