rhai/examples
2022-08-23 16:36:43 +02:00
..
definitions feat(array): add an empty getter for arrays. 2022-08-23 16:36:43 +02:00
event_handler_js Revise required/forbidden features in examples. 2022-07-26 17:05:42 +08:00
event_handler_main Use turbofish for impl Trait. 2022-08-12 22:48:15 +08:00
event_handler_map Use turbofish for impl Trait. 2022-08-12 22:48:15 +08:00
arrays_and_structs.rs Revise required/forbidden features in examples. 2022-07-26 17:05:42 +08:00
callback.rs Expand callback example. 2022-02-16 09:12:34 +08:00
custom_types_and_methods.rs Revise required/forbidden features in examples. 2022-07-26 17:05:42 +08:00
custom_types.rs Merge remote-tracking branch 'other/master' into type_builder_iterable 2022-08-10 17:31:17 +02:00
hello.rs Add comments to examples. 2022-02-12 12:41:04 +08:00
README.md add example 2022-08-09 10:36:33 +02:00
reuse_scope.rs Add comments to examples. 2022-02-12 12:41:04 +08:00
serde.rs Revise required/forbidden features in examples. 2022-07-26 17:05:42 +08:00
simple_fn.rs Add comments to examples. 2022-02-12 12:41:04 +08:00
strings.rs Add comments to examples. 2022-02-12 12:41:04 +08:00
threading.rs Add comments to examples. 2022-02-12 12:41:04 +08:00

Sample Applications

Standard Examples

Example Description
arrays_and_structs shows how to register a Rust type and using it with arrays
callback shows how to store a Rhai closure and call it later within Rust
custom_types_and_methods shows how to register a Rust type and methods/getters/setters for it
custom_types shows how to register a Rust type and methods/getters/setters using the CustomType trait.
definitions shows how to generate definition files for use with the Rhai Language Server (requires the metadata feature)
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}