Book updates for Plugins

This commit is contained in:
J Henry Waugh
2020-08-31 19:03:45 -05:00
parent 91b4f8a6bc
commit c5b2debf4a
3 changed files with 92 additions and 84 deletions

View File

@@ -1,5 +1,5 @@
Create a Plugin Function
========================
Exporting a Rust Function to Rhai
=================================
{{#include ../links.md}}
@@ -13,10 +13,9 @@ Macros
| Macro | Apply to | Behavior |
| ------------------------ | ------------------------------------------------------------- | --------------------------------------------------------- |
| `#[export_fn]` | Rust function defined in module | Export the function |
| `#[rhai_fn(return_raw)]` | Rust function returning `Result<Dynamic, Box<EvalAltResult>>` | Specify that this is a [fallible function] |
| `register_exported_fn!` | [`Engine`] instance, register name, function name | Register function into the [`Engine`] under specific name |
| `set_exported_fn!` | [`Module`], register name, function name | Register function into the [`Module`] under specific name |
| `#[export_fn]` | Rust function defined in a Rust module | Export the function |
| `register_exported_fn!` | [`Engine`] instance, register name string, use path to function | Register function into an [`Engine`] under specific name |
| `set_exported_fn!` | [`Module`] instance, register name string, use path to function | Register function into an [`Module`] under specific name |
`#[export_fn]` and `register_exported_fn!`