https://github.com/phoenixr-codes/rhai-env
Provides inspection and manipulation utilties of the process's environment for the Rhai scripting language.
https://github.com/phoenixr-codes/rhai-env
enbedded rhai rust script
Last synced: 23 days ago
JSON representation
Provides inspection and manipulation utilties of the process's environment for the Rhai scripting language.
- Host: GitHub
- URL: https://github.com/phoenixr-codes/rhai-env
- Owner: phoenixr-codes
- License: apache-2.0
- Created: 2024-12-18T22:08:58.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-18T22:44:36.000Z (over 1 year ago)
- Last Synced: 2026-03-11T21:59:01.162Z (3 months ago)
- Topics: enbedded, rhai, rust, script
- Language: Rust
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE.txt
Awesome Lists containing this project
README
# About `rhai-env`
[](https://crates.io/crates/rhai-env/)
[](https://crates.io/crates/rhai-env/)
[](https://docs.rs/rhai-env/)
This crate provides inspection and manipulation utilties of the process's environment for the
[Rhai] scripting language.
This crate is heavily inspired by [rhai-fs][].
## Usage
### `Cargo.toml`
```toml
[dependencies]
rhai-env = "0.1.2"
```
### [Rhai] script
```js
let foo = read_env("FOO");
set_env("BAR", "blah");
```
### Rust source
```rust
use rhai::{Engine, EvalAltResult};
use rhai::packages::Package;
use rhai_env::EnvironmentPackage;
fn main() -> Result<(), Box> {
// Create Rhai scripting engine
let mut engine = Engine::new();
// Create environment package and add the package into the engine
let package = EnvironmentPackage::new();
package.register_into_engine(&mut engine);
// Print the value of the environment variable `PATH`.
let value = engine.eval::(r#"env("PATH")"#)?;
println!("{}", value);
Ok(())
}
```
## Features
| Feature | Default | Description |
| :--------: | :------: | ---------------------------------------------------- |
| `no_index` | disabled | Enables support for `no_index` builds of [Rhai] |
| `sync` | disabled | Enables support for `sync` builds of [Rhai] |
| `metadata` | disabled | Enables support for generating package documentation |
[Rhai]: https://rhai.rs
[rhai-fs]: https://github.com/rhaiscript/rhai-fs