2 unstable releases
new 0.96.0 | Jan 10, 2025 |
---|---|
0.95.0 | Jan 8, 2025 |
#684 in Hardware support
261 downloads per month
Used in rusp
510KB
11K
SLoC
rhai-rusp
rhai-rusp
is a new approach to address your USP protocol needs by
providing Rhai bindings for the rusp-lib crate, thus providing scripting capabilities
to USP in Rhai for either standalone runners or Rust applications which can
embed the Rhai interpreter together with the rhai-rusp
bindings.
How to embed rhai-rusp
?
rhai-rusp
can be used as a library in your own Rust applications to embed a
Rhai interpreter . To use rhai-rusp
as a library, you simply need to add the
rhai-rusp
crate to your Cargo.toml
as dependency:
[dependencies]
rhai-rusp = "0.96.0"
The usual steps to embed a Rhai interpreter with rusp support are:
- Initialise a Rhai engine via
rhai::Engine::new()
- Add the
rusp
bindings into the namespace perengine.register_static_module("rusp", RuspPackage::new().as_shared_module())
- Compile the
Rhai
code into an AST viaengine.compile(contents)
- Execute the
Rhai
AST viaengine.run_ast(ast)
- Handle errors, err... profit!
There's also the rusp-run
binary as part of the rusp crate which you can install via:
# cargo install rusp
What else?
You may use this crate however you like under the BSD 3-Clause Licence.
Feel free to spread the word or drop us a note if you like it. Collaboration on this crate is highly welcome as are pull requests in our GitHub repo.
Contact us
If you are in need of software for USP management software (agent, controller or testing) or expertise please get in touch with us. We're also happy to solve all other device management and monitoring needs!
Licence
Dependencies
~6.5MB
~121K SLoC