rhai/examples
Stephen Chung 2caf686e8a Fix links.
2022-02-12 11:50:53 +08:00
..
event_handler_js Refactor and add state to debugger. 2022-01-28 18:59:18 +08:00
event_handler_main Refactor and add state to debugger. 2022-01-28 18:59:18 +08:00
event_handler_map Refactor and add state to debugger. 2022-01-28 18:59:18 +08:00
arrays_and_structs.rs Improve examples. 2022-02-10 12:54:30 +08:00
custom_types_and_methods.rs Improve examples. 2022-02-10 12:54:30 +08:00
hello.rs Improve examples. 2022-02-10 12:54:30 +08:00
README.md Fix links. 2022-02-12 11:50:53 +08:00
reuse_scope.rs Use run and i64 instead of eval and INT for examples. 2022-01-11 22:12:46 +08:00
serde.rs Revert "Refine examples." 2022-01-16 22:50:39 +08:00
simple_fn.rs Use run and i64 instead of eval and INT for examples. 2022-01-11 22:12:46 +08:00
strings.rs Revert "Refine examples." 2022-01-16 22:50:39 +08:00
threading.rs Use run and i64 instead of eval and INT for examples. 2022-01-11 22:12:46 +08:00

Sample Applications

Standard Examples

Example Description
arrays_and_structs shows how to register a Rust type and using it with arrays
custom_types_and_methods shows how to register a Rust type and methods/getters/setters for it
hello simple example that evaluates an expression and prints the result
reuse_scope evaluates two pieces of code in separate runs, but using a common Scope
serde example to serialize and deserialize Rust types with serde (requires the serde feature)
simple_fn shows how to register a simple Rust function
strings shows different ways to register Rust functions taking string arguments
threading shows how to communicate with an Engine running in a separate thread via an MPSC channel

Scriptable Event Handler With State Examples

Because of its popularity, included are sample implementations for the pattern Scriptable Event Handler With State in different styles.

Example Handler Script Description
event_handler_main event_handler_main/script.rhai Main Style
event_handler_js event_handler_js/script.rhai JS Style
event_handler_map event_handler_map/script.rhai Map Style

Running Examples

Examples can be run with the following command:

cargo run --example {example_name}