| Crates.io | rhai-env |
| lib.rs | rhai-env |
| version | 0.1.2 |
| created_at | 2024-12-18 22:10:13.469579+00 |
| updated_at | 2024-12-18 22:29:07.94817+00 |
| description | Environment package for Rhai |
| homepage | |
| repository | https://github.com/phoenixr-codes/rhai-env |
| max_upload_size | |
| id | 1488536 |
| size | 39,618 |
rhai-envThis crate provides inspection and manipulation utilties of the process's environment for the Rhai scripting language.
This crate is heavily inspired by rhai-fs.
Cargo.toml[dependencies]
rhai-env = "0.1.0"
let foo = read_env("FOO");
set_env("BAR", "blah");
use rhai::{Engine, EvalAltResult};
use rhai::packages::Package;
use rhai_env::EnvironmentPackage;
fn main() -> Result<(), Box<EvalAltResult>> {
// 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::<String>(r#"env("PATH")"#)?;
println!("{}", value);
Ok(())
}
| 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 |