From 447c11da17f9a222bb888c0489eae8ec6dcbce85 Mon Sep 17 00:00:00 2001 From: Byson94 Date: Sat, 30 Aug 2025 20:27:30 +0530 Subject: [PATCH] wip: Massive doc automation and improvement. --- CHANGELOG.md | 2 + Cargo.lock | 246 +- Cargo.toml | 2 +- crates/iirhai/src/providers/mod.rs | 7 +- crates/iirhai/src/providers/stdlib/command.rs | 39 + crates/iirhai/src/providers/stdlib/env.rs | 89 +- crates/iirhai/src/providers/stdlib/json.rs | 45 - crates/iirhai/src/providers/stdlib/math.rs | 157 - crates/iirhai/src/providers/stdlib/mod.rs | 8 +- crates/iirhai/src/providers/stdlib/monitor.rs | 157 +- crates/iirhai/src/providers/stdlib/text.rs | 93 + docs/book.toml | 4 +- docs/src/SUMMARY.md | 1 + docs/src/modules/apilib.md | 307 +- docs/src/modules/global.md | 6642 ++++++++++++++++ docs/src/modules/stdlib.md | 1238 ++- docs/theme/rhai-autodocs/default.css | 54 + docs/theme/rhai-autodocs/tabs.js | 23 + heaptrack.ewwii.320299.zst | Bin 17755 -> 0 bytes tools/README.md | 13 + tools/generate-rhai-docs/.gitignore | 1 + tools/generate-rhai-docs/Cargo.lock | 612 ++ tools/generate-rhai-docs/Cargo.toml | 9 + tools/generate-rhai-docs/rhai_docs/global.md | 6655 +++++++++++++++++ tools/generate-rhai-docs/src/main.rs | 63 + 25 files changed, 15920 insertions(+), 547 deletions(-) delete mode 100644 crates/iirhai/src/providers/stdlib/json.rs delete mode 100644 crates/iirhai/src/providers/stdlib/math.rs create mode 100644 docs/src/modules/global.md create mode 100644 docs/theme/rhai-autodocs/default.css create mode 100644 docs/theme/rhai-autodocs/tabs.js delete mode 100644 heaptrack.ewwii.320299.zst create mode 100644 tools/README.md create mode 100644 tools/generate-rhai-docs/.gitignore create mode 100644 tools/generate-rhai-docs/Cargo.lock create mode 100644 tools/generate-rhai-docs/Cargo.toml create mode 100644 tools/generate-rhai-docs/rhai_docs/global.md create mode 100644 tools/generate-rhai-docs/src/main.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 83dbd6b..2116f51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/). ### Removed - Deprecated attribute warning which cluttered the logs. +- `std::json` (Rhai has built in json support). +- `std::math` (Rhai already convers everything that it has). ## [0.1.0-beta] - 2025-08-27 diff --git a/Cargo.lock b/Cargo.lock index 1114854..be36c43 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -382,7 +382,7 @@ dependencies = [ "glib", "libc", "once_cell", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -626,6 +626,41 @@ dependencies = [ "typenum", ] +[[package]] +name = "darling" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.87", +] + +[[package]] +name = "darling_macro" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.87", +] + [[package]] name = "dbusmenu-glib" version = "0.1.0" @@ -690,6 +725,37 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_builder" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "derive_builder_macro" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" +dependencies = [ + "derive_builder_core", + "syn 2.0.87", +] + [[package]] name = "derive_more" version = "1.0.0" @@ -860,7 +926,7 @@ dependencies = [ "smart-default", "static_assertions", "sysinfo", - "thiserror", + "thiserror 1.0.64", "tokio", "tokio-util", "unescape", @@ -929,6 +995,12 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "fsevent-sys" version = "4.1.0" @@ -1137,6 +1209,15 @@ dependencies = [ "x11", ] +[[package]] +name = "generate-rhai-docs" +version = "0.1.0" +dependencies = [ + "iirhai", + "rhai", + "rhai-autodocs", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -1204,7 +1285,7 @@ dependencies = [ "once_cell", "pin-project-lite", "smallvec", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -1240,7 +1321,7 @@ dependencies = [ "memchr", "once_cell", "smallvec", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -1383,6 +1464,22 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "handlebars" +version = "6.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759e2d5aea3287cb1190c8ec394f42866cb5bf74fcbf213f354e3c856ea26098" +dependencies = [ + "derive_builder", + "log", + "num-order", + "pest", + "pest_derive", + "serde", + "serde_json", + "thiserror 2.0.16", +] + [[package]] name = "hashbrown" version = "0.14.5" @@ -1452,6 +1549,12 @@ dependencies = [ "cc", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "iirhai" version = "0.1.0" @@ -1472,7 +1575,7 @@ dependencies = [ "sysinfo", "termsize", "textwrap", - "thiserror", + "thiserror 1.0.64", "tokio", "tokio-util", ] @@ -1744,7 +1847,7 @@ dependencies = [ "log", "quick-xml", "serde", - "thiserror", + "thiserror 1.0.64", "tokio", "zbus", ] @@ -1777,6 +1880,21 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-modular" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17bb261bf36fa7d83f4c294f834e91256769097b3cb505d44831e0a179ac647f" + +[[package]] +name = "num-order" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "537b596b97c40fcf8056d153049eb22f481c17ebce72a513ec9286e4986d1bb6" +dependencies = [ + "num-modular", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -1868,6 +1986,50 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "pest" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323" +dependencies = [ + "memchr", + "thiserror 2.0.16", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb056d9e8ea77922845ec74a1c4e8fb17e7c218cc4fc11a15c5d25e189aa40bc" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e404e638f781eb3202dc82db6760c8ae8a1eeef7fb3fa8264b2ef280504966" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "pest_meta" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd1101f170f5903fde0914f899bb503d9ff5271d7ba76bbb70bea63690cc0d5" +dependencies = [ + "pest", + "sha2", +] + [[package]] name = "phf" version = "0.11.2" @@ -2208,11 +2370,25 @@ dependencies = [ "num-traits", "once_cell", "rhai_codegen", + "serde", + "serde_json", "smallvec", "smartstring", "thin-vec", ] +[[package]] +name = "rhai-autodocs" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ebabdcbc322e497a1a6d20a18b2c667db2eaf8246d0e3288def5648af86c46a" +dependencies = [ + "handlebars", + "rhai", + "serde", + "serde_json", +] + [[package]] name = "rhai_codegen" version = "2.2.0" @@ -2295,18 +2471,18 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.215" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.215" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", @@ -2315,9 +2491,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.143" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a" dependencies = [ "itoa", "memchr", @@ -2356,6 +2532,17 @@ dependencies = [ "digest", ] +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "shlex" version = "1.3.0" @@ -2401,6 +2588,9 @@ name = "smallvec" version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +dependencies = [ + "serde", +] [[package]] name = "smart-default" @@ -2420,6 +2610,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" dependencies = [ "autocfg", + "serde", "static_assertions", "version_check", ] @@ -2578,6 +2769,9 @@ name = "thin-vec" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "144f754d318415ac792f9d69fc87abbbfc043ce2ef041c60f16ad828f638717d" +dependencies = [ + "serde", +] [[package]] name = "thiserror" @@ -2585,7 +2779,16 @@ version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.64", +] + +[[package]] +name = "thiserror" +version = "2.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" +dependencies = [ + "thiserror-impl 2.0.16", ] [[package]] @@ -2599,6 +2802,17 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "thiserror-impl" +version = "2.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "tiny-keccak" version = "2.0.2" @@ -2733,6 +2947,12 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + [[package]] name = "uds_windows" version = "1.1.0" diff --git a/Cargo.toml b/Cargo.toml index dcdd159..7987ed4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["crates/*"] +members = ["crates/*", "tools/*"] resolver = "2" [workspace.dependencies] diff --git a/crates/iirhai/src/providers/mod.rs b/crates/iirhai/src/providers/mod.rs index 69b271b..0473a17 100644 --- a/crates/iirhai/src/providers/mod.rs +++ b/crates/iirhai/src/providers/mod.rs @@ -7,17 +7,18 @@ for providing data or doing certain actions. */ -mod apilib; mod builtin_signals; mod helper; mod stdlib; +mod apilib; use crate::module_resolver::{ChainedResolver, SimpleFileResolver}; use rhai::module_resolvers::StaticModuleResolver; -use apilib::register_apilib; use builtin_signals::register_all_signals; -use stdlib::register_stdlib; +// expose the api's publically +pub use stdlib::register_stdlib; +pub use apilib::register_apilib; pub fn register_all_providers(engine: &mut rhai::Engine) { let mut resolver = StaticModuleResolver::new(); diff --git a/crates/iirhai/src/providers/stdlib/command.rs b/crates/iirhai/src/providers/stdlib/command.rs index b3dd7e6..35eb809 100644 --- a/crates/iirhai/src/providers/stdlib/command.rs +++ b/crates/iirhai/src/providers/stdlib/command.rs @@ -4,6 +4,25 @@ use std::process::Command; #[export_module] pub mod command { + /// Executes a shell command without capturing the output. + /// + /// # Arguments + /// + /// * `cmd` - The shell command to execute as a string. + /// + /// # Returns + /// + /// This function returns nothing if the command executes successfully. If there is an error + /// running the command, it returns the error. + /// + /// # Example + /// + /// ```js + /// import "std::command" as cmd; + /// + /// // Run a shell command (e.g., list directory contents) + /// cmd::run("ls -l"); + /// ``` #[rhai_fn(return_raw)] pub fn run(cmd: &str) -> Result<(), Box> { Command::new("sh") @@ -14,6 +33,26 @@ pub mod command { Ok(()) } + /// Executes a shell command and captures its output. + /// + /// # Arguments + /// + /// * `cmd` - The shell command to execute as a string. + /// + /// # Returns + /// + /// This function returns the standard output of the command as a `string`. If the command fails, + /// it returns the error. + /// + /// # Example + /// + /// ```js + /// import "std::command" as cmd; + /// + /// // Run a shell command and capture its output + /// let output = cmd::run_and_read("echo 'Hello, world!'"); + /// print(output); // output: Hello, world! + /// ``` #[rhai_fn(return_raw)] pub fn run_and_read(cmd: &str) -> Result> { let output = Command::new("sh") diff --git a/crates/iirhai/src/providers/stdlib/env.rs b/crates/iirhai/src/providers/stdlib/env.rs index f6b16dd..090af5a 100644 --- a/crates/iirhai/src/providers/stdlib/env.rs +++ b/crates/iirhai/src/providers/stdlib/env.rs @@ -3,29 +3,116 @@ use rhai::EvalAltResult; #[export_module] pub mod env { + /// Get the value of an environment variable. + /// + /// # Arguments + /// + /// * `var` - The name of the environment variable to retrieve. + /// + /// # Returns + /// + /// This function returns the value of the environment variable as a `String`. + /// If the variable is not found or there is an error, it returns a `Result::Err` with the error message. + /// + /// # Example + /// + /// ```js + /// import "std::env" as env; + /// + /// // Get the value of the "HOME" environment variable + /// let home_dir = env::get_env("HOME"); + /// print(home_dir); // output: /home/username + /// ``` #[rhai_fn(return_raw)] pub fn get_env(var: &str) -> Result> { std::env::var(var).map_err(|e| format!("Failed to get env: {e}").into()) } + /// Set the value of an environment variable. + /// + /// # Arguments + /// + /// * `var` - The name of the environment variable to set. + /// * `value` - The value to assign to the environment variable. + /// + /// # Returns + /// + /// This function does not return a value. + /// + /// # Example + /// + /// ```js + /// import "std::env" as env; + /// + /// // Set the value of the "MY_VAR" environment variable + /// env::set_env("MY_VAR", "SomeValue"); + /// ``` pub fn set_env(var: &str, value: &str) { std::env::set_var(var, value); } + /// Get the path to the home directory. + /// + /// # Returns + /// + /// This function returns the value of the "HOME" environment variable as a `String`. + /// If the variable is not found or there is an error, it returns a `Result::Err` with the error message. + /// + /// # Example + /// + /// ```js + /// import "std::env" as env; + /// + /// // Get the home directory + /// let home_dir = env::get_home_dir(); + /// print(home_dir); // output: /home/username + /// ``` #[rhai_fn(return_raw)] pub fn get_home_dir() -> Result> { std::env::var("HOME").map_err(|e| format!("Failed to get home directory: {e}").into()) } + /// Get the current working directory. + /// + /// # Returns + /// + /// This function returns the current working directory as a `String`. If there is an error + /// (e.g., if the path cannot be retrieved), it returns a `Result::Err` with the error message. + /// + /// # Example + /// + /// ```js + /// import "std::env" as env; + /// + /// // Get the current working directory + /// let current_dir = env::get_current_dir(); + /// print(current_dir); // output: /home/username/project + /// ``` #[rhai_fn(return_raw)] pub fn get_current_dir() -> Result> { std::env::current_dir() - .map_err(|e| format!("Failed to get CURRENT DIRECTORY: {e}").into()) + .map_err(|e| format!("Failed to get current directory: {e}").into()) .and_then(|p| { p.into_os_string().into_string().map_err(|_| "Invalid path encoding".into()) }) } + /// Get the current username. + /// + /// # Returns + /// + /// This function returns the value of the "USER" environment variable as a `String`. + /// If the variable is not found or there is an error, it returns a `Result::Err` with the error message. + /// + /// # Example + /// + /// ```js + /// import "std::env" as env; + /// + /// // Get the username of the current user + /// let username = env::get_username(); + /// print(username); // output: username + /// ``` #[rhai_fn(return_raw)] pub fn get_username() -> Result> { std::env::var("USER").map_err(|e| format!("Failed to get USER: {e}").into()) diff --git a/crates/iirhai/src/providers/stdlib/json.rs b/crates/iirhai/src/providers/stdlib/json.rs deleted file mode 100644 index cfccab8..0000000 --- a/crates/iirhai/src/providers/stdlib/json.rs +++ /dev/null @@ -1,45 +0,0 @@ -use rhai::plugin::*; -use rhai::Dynamic; -use rhai::EvalAltResult; -use serde_json::Value; - -#[export_module] -pub mod json { - // parse a JSON string into a Dynamic representing serde_json::Value - #[rhai_fn(return_raw)] - pub fn parse_json(json_str: &str) -> Result> { - serde_json::from_str::(json_str) - .map(Dynamic::from) - .map_err(|e| format!("Failed to parse JSON: {e}").into()) - } - - // Turn a dyn JSON val back to a string - #[rhai_fn(return_raw)] - pub fn to_string(json: Dynamic) -> Result> { - let value: Value = json.try_cast::().ok_or("Expected a JSON value")?; - serde_json::to_string(&value).map_err(|e| format!("Failed to serialize JSON: {e}").into()) - } - - // get a key in a JSON object - #[rhai_fn(return_raw)] - pub fn get(json: Dynamic, key: &str) -> Result> { - let value: Value = json.try_cast::().ok_or("Expected a JSON object")?; - match value.get(key) { - Some(v) => Ok(Dynamic::from(v.clone())), - None => Ok(Dynamic::UNIT), - } - } - - // Set a key in a JSON object - #[rhai_fn(return_raw)] - pub fn set(json: Dynamic, key: &str, value: Dynamic) -> Result<(), Box> { - let mut map: Value = json.try_cast::().ok_or("Expected a JSON object")?; - if let Value::Object(ref mut obj) = map { - let v: Value = value.try_cast::().ok_or("Expected JSON value")?; - obj.insert(key.to_string(), v); - Ok(()) - } else { - Err("JSON value is not an object".into()) - } - } -} diff --git a/crates/iirhai/src/providers/stdlib/math.rs b/crates/iirhai/src/providers/stdlib/math.rs deleted file mode 100644 index ebb5830..0000000 --- a/crates/iirhai/src/providers/stdlib/math.rs +++ /dev/null @@ -1,157 +0,0 @@ -use rhai::plugin::*; -use rhai::EvalAltResult; - -#[export_module] -pub mod math { - // math constants - pub const PI: f64 = std::f64::consts::PI; - pub const E: f64 = std::f64::consts::E; - pub const TAU: f64 = std::f64::consts::TAU; - - // basics - pub fn abs(x: f64) -> f64 { - x.abs() - } - - #[rhai_fn(return_raw)] - pub fn sqrt(x: f64) -> Result> { - if x < 0.0 { - Err("Math error: sqrt of negative number".into()) - } else { - Ok(x.sqrt()) - } - } - - pub fn pow(base: f64, exp: f64) -> f64 { - base.powf(exp) - } - - pub fn sin(x: f64) -> f64 { - x.sin() - } - pub fn cos(x: f64) -> f64 { - x.cos() - } - pub fn tan(x: f64) -> f64 { - x.tan() - } - - // exponentiation - pub fn exp(x: f64) -> f64 { - x.exp() - } - - #[rhai_fn(return_raw)] - pub fn ln(x: f64) -> Result> { - if x <= 0.0 { - Err("Math error: ln of non-positive number".into()) - } else { - Ok(x.ln()) - } - } - - #[rhai_fn(return_raw)] - pub fn log10(x: f64) -> Result> { - if x <= 0.0 { - Err("Math error: log10 of non-positive number".into()) - } else { - Ok(x.log10()) - } - } - - #[rhai_fn(return_raw)] - pub fn log(base: f64, x: f64) -> Result> { - if base <= 0.0 || base == 1.0 { - Err("Math error: invalid base for log".into()) - } else if x <= 0.0 { - Err("Math error: log of non-positive number".into()) - } else { - Ok(x.log(base)) - } - } - - // advanced - #[rhai_fn(return_raw)] - pub fn asin(x: f64) -> Result> { - if x < -1.0 || x > 1.0 { - Err("Math error: asin input out of range [-1,1]".into()) - } else { - Ok(x.asin()) - } - } - - #[rhai_fn(return_raw)] - pub fn acos(x: f64) -> Result> { - if x < -1.0 || x > 1.0 { - Err("Math error: acos input out of range [-1,1]".into()) - } else { - Ok(x.acos()) - } - } - - pub fn atan(x: f64) -> f64 { - x.atan() - } - pub fn atan2(y: f64, x: f64) -> f64 { - y.atan2(x) - } - - pub fn sinh(x: f64) -> f64 { - x.sinh() - } - pub fn cosh(x: f64) -> f64 { - x.cosh() - } - pub fn tanh(x: f64) -> f64 { - x.tanh() - } - - pub fn floor(x: f64) -> f64 { - x.floor() - } - pub fn ceil(x: f64) -> f64 { - x.ceil() - } - pub fn round(x: f64) -> f64 { - x.round() - } - pub fn trunc(x: f64) -> f64 { - x.trunc() - } - pub fn fract(x: f64) -> f64 { - x.fract() - } - - pub fn min(a: f64, b: f64) -> f64 { - a.min(b) - } - pub fn max(a: f64, b: f64) -> f64 { - a.max(b) - } - pub fn clamp(x: f64, min: f64, max: f64) -> f64 { - x.clamp(min, max) - } - - // other api's - #[rhai_fn(return_raw)] - pub fn to_float(x: Dynamic) -> Result> { - if let Some(f) = x.clone().try_cast::() { - Ok(f) - } else if let Some(i) = x.try_cast::() { - Ok(i as f64) - } else { - Err("Expected a number".into()) - } - } - - #[rhai_fn(return_raw)] - pub fn to_int(x: Dynamic) -> Result> { - if let Some(i) = x.clone().try_cast::() { - Ok(i) - } else if let Some(f) = x.try_cast::() { - Ok(f as i64) - } else { - Err("Expected a number".into()) - } - } -} diff --git a/crates/iirhai/src/providers/stdlib/mod.rs b/crates/iirhai/src/providers/stdlib/mod.rs index 6e33a02..67cafcb 100644 --- a/crates/iirhai/src/providers/stdlib/mod.rs +++ b/crates/iirhai/src/providers/stdlib/mod.rs @@ -1,7 +1,5 @@ pub mod command; pub mod env; -pub mod json; -pub mod math; pub mod monitor; pub mod text; @@ -10,22 +8,18 @@ use rhai::module_resolvers::StaticModuleResolver; pub fn register_stdlib(resolver: &mut StaticModuleResolver) { use crate::providers::stdlib::{ - command::command, env::env, json::json, math::math, monitor::monitor, text::text, + command::command, env::env, monitor::monitor, text::text, }; // adding modules let text_mod = exported_module!(text); let env_mod = exported_module!(env); let monitor_mod = exported_module!(monitor); - let json_mod = exported_module!(json); - let math_mod = exported_module!(math); let command_mod = exported_module!(command); // inserting modules resolver.insert("std::text", text_mod); resolver.insert("std::env", env_mod); resolver.insert("std::monitor", monitor_mod); - resolver.insert("std::json", json_mod); - resolver.insert("std::math", math_mod); resolver.insert("std::command", command_mod); } diff --git a/crates/iirhai/src/providers/stdlib/monitor.rs b/crates/iirhai/src/providers/stdlib/monitor.rs index 18fef30..dac77be 100644 --- a/crates/iirhai/src/providers/stdlib/monitor.rs +++ b/crates/iirhai/src/providers/stdlib/monitor.rs @@ -4,24 +4,97 @@ use rhai::plugin::*; #[export_module] pub mod monitor { + /// Get the number of connected monitors. + /// + /// # Returns + /// + /// Returns the total number of connected monitors as an `i64`. + /// + /// # Example + /// + /// ```js + /// import "std::monitor" as monitor; + /// + /// let count = monitor::count(); + /// print(count); // Output: Number of connected monitors + /// ``` pub fn count() -> i64 { get_monitor_count() } - pub fn primary_resolution() -> Vec { + /// Get the resolution of the primary monitor. + /// + /// # Returns + /// + /// Returns an array containing the width and height of the primary monitor as two `i64` values. + /// + /// # Example + /// + /// ```js + /// import "std::monitor" as monitor; + /// + /// let resolution = monitor::primary_resolution(); + /// print(resolution); // Output: [width, height] + /// ``` + pub fn primary_resolution() -> [i64; 2] { let (w, h) = get_primary_monitor_resolution(); - vec![w, h] + [w, h] } + /// Get the resolution of the primary monitor as a string. + /// + /// # Returns + /// + /// Returns the resolution of the primary monitor as a string in the format "width x height". + /// + /// # Example + /// + /// ```js + /// import "std::monitor" as monitor; + /// + /// let resolution_str = monitor::primary_resolution_str(); + /// print(resolution_str); // Output: "1920x1080" + /// ``` pub fn primary_resolution_str() -> String { let (w, h) = get_primary_monitor_resolution(); format!("{w}x{h}") } - pub fn all_resolutions() -> Vec> { - get_all_monitor_resolutions().into_iter().map(|(w, h)| vec![w, h]).collect() + /// Get the resolutions of all connected monitors. + /// + /// # Returns + /// + /// Returns an array of arrays, where each inner array contains the width and height of a monitor. + /// + /// # Example + /// + /// ```js + /// import "std::monitor" as monitor; + /// + /// let resolutions = monitor::all_resolutions(); + /// print(resolutions); // Output: [[width1, height1], [width2, height2], ...] + /// ``` + pub fn all_resolutions() -> Vec<[i64; 2]> { + get_all_monitor_resolutions() + .into_iter() + .map(|(w, h)| [w, h]) + .collect() } + /// Get the resolutions of all connected monitors as a string. + /// + /// # Returns + /// + /// Returns a string where each monitor's resolution is formatted as "width x height", separated by commas. + /// + /// # Example + /// + /// ```js + /// import "std::monitor" as monitor; + /// + /// let resolutions_str = monitor::all_resolutions_str(); + /// print(resolutions_str); // Output: "1920x1080, 1280x720" + /// ``` pub fn all_resolutions_str() -> String { get_all_monitor_resolutions() .into_iter() @@ -30,20 +103,92 @@ pub mod monitor { .join(", ") } - pub fn dimensions(index: i64) -> Vec { + /// Get the dimensions (x, y, width, height) of a specific monitor. + /// + /// # Arguments + /// + /// * `index` - The index of the monitor (0-based). + /// + /// # Returns + /// + /// Returns an array with the monitor's position (x, y) and size (width, height). + /// + /// # Example + /// + /// ```js + /// import "std::monitor" as monitor; + /// + /// let dimensions = monitor::dimensions(0); + /// print(dimensions); // Output: [x, y, width, height] + /// ``` + pub fn dimensions(index: i64) -> [i64; 4] { let (x, y, w, h) = get_monitor_dimensions(index as usize); - vec![x, y, w, h] + [x, y, w, h] } + /// Get the dimensions of a specific monitor as a string. + /// + /// # Arguments + /// + /// * `index` - The index of the monitor (0-based). + /// + /// # Returns + /// + /// Returns the monitor's dimensions as a string in the format "x,y - width x height". + /// + /// # Example + /// + /// ```js + /// import "std::monitor" as monitor; + /// + /// let dimensions_str = monitor::dimensions_str(0); + /// print(dimensions_str); // Output: "0,0 - 1920x1080" + /// ``` pub fn dimensions_str(index: i64) -> String { let (x, y, w, h) = get_monitor_dimensions(index as usize); format!("{x},{y} - {w}x{h}") } + /// Get the DPI (dots per inch) of a specific monitor. + /// + /// # Arguments + /// + /// * `index` - The index of the monitor (0-based). + /// + /// # Returns + /// + /// Returns the DPI (scale factor * base DPI) of the monitor as a `f64`. + /// + /// # Example + /// + /// ```js + /// import "std::monitor" as monitor; + /// + /// let dpi = monitor::dpi(0); + /// print(dpi); // Output: DPI of the monitor + /// ``` pub fn dpi(index: i64) -> f64 { get_monitor_dpi(index as usize) } + /// Get the DPI of a specific monitor as a string. + /// + /// # Arguments + /// + /// * `index` - The index of the monitor (0-based). + /// + /// # Returns + /// + /// Returns the DPI of the monitor as a string formatted to 1 decimal place. + /// + /// # Example + /// + /// ```js + /// import "std::monitor" as monitor; + /// + /// let dpi_str = monitor::dpi_str(0); + /// print(dpi_str); // Output: "96.0" + /// ``` pub fn dpi_str(index: i64) -> String { format!("{:.1}", get_monitor_dpi(index as usize)) } diff --git a/crates/iirhai/src/providers/stdlib/text.rs b/crates/iirhai/src/providers/stdlib/text.rs index ce236ad..d56969a 100644 --- a/crates/iirhai/src/providers/stdlib/text.rs +++ b/crates/iirhai/src/providers/stdlib/text.rs @@ -1,7 +1,27 @@ use rhai::plugin::*; +/// A module providing utility functions for string manipulation. #[export_module] pub mod text { + + /// Converts a string to a slug (lowercase words joined by hyphens). + /// + /// # Arguments + /// + /// * `text` - A string to be converted to a slug. + /// + /// # Returns + /// + /// Returns the `text` as a slug. + /// + /// # Example + /// + /// ```js + /// import "std::text" as text; + /// + /// let result = text::to_slug("Hello World!"); + /// print(result); // output: "hello-world" + /// ``` pub fn to_slug(text: &str) -> String { let lower = text.to_lowercase(); @@ -16,6 +36,24 @@ pub mod text { slug } + /// Converts a string to camel case. + /// + /// # Arguments + /// + /// * `text` - A string to be converted to camel case. + /// + /// # Returns + /// + /// Returns the `text` in camel case format. + /// + /// # Example + /// + /// ```js + /// import "std::text" as text; + /// + /// let result = text::to_camel_case("hello world example"); + /// print(result); // output: "helloWorldExample" + /// ``` pub fn to_camel_case(text: &str) -> String { let cleaned: String = text .chars() @@ -42,6 +80,25 @@ pub mod text { camel } + /// Truncates a string to the specified number of characters. + /// + /// # Arguments + /// + /// * `text` - A string to be truncated. + /// * `max_chars` - The maximum number of characters to keep in the string. + /// + /// # Returns + /// + /// Returns a truncated string. + /// + /// # Example + /// + /// ```js + /// import "std::text" as text; + /// + /// let result = text::truncate_chars("Hello World!", 5); + /// print(result); // output: "Hello" + /// ``` pub fn truncate_chars(text: String, max_chars: i64) -> String { match text.char_indices().nth(max_chars.try_into().unwrap()) { None => text, @@ -49,10 +106,46 @@ pub mod text { } } + /// Converts a string to uppercase. + /// + /// # Arguments + /// + /// * `s` - A string to be converted to uppercase. + /// + /// # Returns + /// + /// Returns the string in uppercase. + /// + /// # Example + /// + /// ```js + /// import "std::text" as text; + /// + /// let result = text::to_upper("hello"); + /// print(result); // output: "HELLO" + /// ``` pub fn to_upper(s: &str) -> String { s.to_uppercase() } + /// Converts a string to lowercase. + /// + /// # Arguments + /// + /// * `s` - A string to be converted to lowercase. + /// + /// # Returns + /// + /// Returns the string in lowercase. + /// + /// # Example + /// + /// ```js + /// import "std::text" as text; + /// + /// let result = text::to_lower("HELLO"); + /// print(result); // output: "hello" + /// ``` pub fn to_lower(s: &str) -> String { s.to_lowercase() } diff --git a/docs/book.toml b/docs/book.toml index 847cac3..f05127a 100644 --- a/docs/book.toml +++ b/docs/book.toml @@ -10,5 +10,5 @@ default-theme = "latte" preferred-dark-theme = "ewwii" site-url = "/ewwii/" git-repository-url = "https://github.com/Ewwii-sh/ewwii" -additional-js = ["js/home_button.js"] -additional-css = ["./theme/catppuccin.css", "./theme/ewwii.css"] \ No newline at end of file +additional-js = ["./js/home_button.js", "./theme/rhai-autodocs/tabs.js"] +additional-css = ["./theme/catppuccin.css", "./theme/ewwii.css", "./theme/rhai-autodocs/default.css"] \ No newline at end of file diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 2ac848a..36c274f 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -24,6 +24,7 @@ - [Modules](modules/modules.md) - [User Defined Modules](modules/user_defined.md) + - [Global Builtin Rhai Functions](modules/global.md) - [Std Library](modules/stdlib.md) - [API Library](modules/apilib.md) diff --git a/docs/src/modules/apilib.md b/docs/src/modules/apilib.md index fa93ef9..8c7cf1f 100644 --- a/docs/src/modules/apilib.md +++ b/docs/src/modules/apilib.md @@ -1,81 +1,254 @@ -# API Library +# env -## `api::wifi` +`Namespace: global/std/env` -The `wifi` module provides cross-platform Wi-Fi management for Linux and macOS systems. Functions include scanning networks, querying the current connection, connecting/disconnecting, and enabling/disabling the Wi-Fi adapter. +
+

fn get_current_dir

-> **Note:** macOS support is largely untested and may behave differently depending on system configuration. - -### Usage - -```js -import "api::wifi" as wifi; - -// Scan for available networks -let networks = wifi::scan(); - -// Get current Wi-Fi connection info -let current = wifi::current_connection(); - -// Connect to a network with password -wifi::connect("MySSID", "MyPassword"); - -// Connect to a network without password (using saved profile) -wifi::connect_without_password("MySSID"); - -// Disconnect from the current network -wifi::disconnect(); - -// Enable/disable the Wi-Fi adapter -wifi::enable_adapter(); -wifi::disable_adapter(); - -// Get adapter connection -wifi::get_adapter_connectivity(); +```rust,ignore +fn get_current_dir() -> String ``` -### Functions +
+
+ + + +
-| Function | Description | -| -------------------------------- | ----------------------------------------------------------------------------------------------- | -| `scan()` | Returns a list of nearby Wi-Fi networks with `ssid`, `signal`, and `security` fields. | -| `scan_linux()` | **Linux only**. Returns a list of nearby Wi-Fi networks. Equivalent to `scan()`. | -| `scan_macos()` | **macOS only (untested)**. Returns a list of nearby Wi-Fi networks. Equivalent to `scan()`. | -| `current_connection()` | Returns information about the current Wi-Fi connection as a map (`ssid`, `signal`, `security`). | -| `connect(ssid, password)` | Connects to a Wi-Fi network. | -| `connect_without_password(ssid)` | Connects to a Wi-Fi network without password by using the saved profile. | -| `disconnect()` | Disconnects from the currently connected network (does not disable the adapter). | -| `enable_adapter()` | Turns the Wi-Fi adapter on. | -| `get_adapter_connectivity()` | Returns a normalized connectivity status of the Wi-Fi adapter. | +
+Get the current working directory. +
+ + -```js -{ "ssid": "HomeWiFi", "signal": "78", "security": "WPA2" } +
+
+
+
+

fn get_env

+ +```rust,ignore +fn get_env(var: String) -> String ``` + +
+
+ + + + +
+ +
+Get the value of an environment variable. +
+ + + + +
+
+
+
+

fn get_home_dir

+ +```rust,ignore +fn get_home_dir() -> String +``` + +
+
+ + + +
+ +
+Get the path to the home directory. +
+ + + +
+
+
+
+

fn get_username

+ +```rust,ignore +fn get_username() -> String +``` + +
+
+ + + +
+ +
+Get the current username. +
+ + + +
+
+
+
+

fn set_env

+ +```rust,ignore +fn set_env(var: String, value: String) +``` + +
+
+ + + + +
+ +
+Set the value of an environment variable. +
+ + + + +
+
+
diff --git a/docs/src/modules/global.md b/docs/src/modules/global.md new file mode 100644 index 0000000..3cd0f64 --- /dev/null +++ b/docs/src/modules/global.md @@ -0,0 +1,6642 @@ +# global + +```Namespace: global``` + +
+

op !=

+ +```rust,ignore +op u128 != u128 -> bool +op int != f32 -> bool +op Map != Map -> bool +op u64 != u64 -> bool +op f32 != f32 -> bool +op i8 != i8 -> bool +op i32 != i32 -> bool +op Instant != Instant -> bool +op u8 != u8 -> bool +op i128 != i128 -> bool +op f32 != int -> bool +op i16 != i16 -> bool +op u32 != u32 -> bool +op Array != Array -> bool +op u16 != u16 -> bool +``` + +
+
+ + +
+ +
+Return `true` if two object maps are not equal (i.e. at least one property value is not equal). + +The operator `==` is used to compare property values and must be defined, +otherwise `false` is assumed. +
+ + +
+
+
+
+

fn +

+ +```rust,ignore +fn +(x: int) -> int +fn +(x: i32) -> i32 +fn +(x: i8) -> i8 +fn +(x: i128) -> i128 +fn +(x: f32) -> f32 +fn +(x: float) -> float +fn +(x: i16) -> i16 +fn +(x: u32, y: u32) -> u32 +fn +(array1: Array, array2: Array) -> Array +fn +(string: String, character: char) -> String +fn +(x: u16, y: u16) -> u16 +fn +(x: i16, y: i16) -> i16 +fn +(string: String, mut item: ?) -> String +fn +(x: f32, y: int) -> f32 +fn +(string: String, item: ?) -> String +fn +(utf8: Blob, string: String) -> String +fn +(character: char, string: String) -> String +fn +(string1: String, string2: String) -> String +fn +(x: i128, y: i128) -> i128 +fn +(x: u8, y: u8) -> u8 +fn +(timestamp: Instant, seconds: int) -> Instant +fn +(x: i32, y: i32) -> i32 +fn +(item: ?, string: String) -> String +fn +(x: f32, y: f32) -> f32 +fn +(x: i8, y: i8) -> i8 +fn +(x: u64, y: u64) -> u64 +fn +(x: int, y: f32) -> f32 +fn +(map1: Map, map2: Map) -> Map +fn +(item: ?, string: String) -> String +fn +(timestamp: Instant, seconds: float) -> Instant +fn +(x: u128, y: u128) -> u128 +fn +(string: String, utf8: Blob) -> String +``` + +
+
+ + +
+ +
+Combine two arrays into a new array and return it. +
+ + +
+
+
+
+

fn +=

+ +```rust,ignore +fn +=(string1: String, string2: String) +fn +=(timestamp: Instant, seconds: int) +fn +=(string: String, character: char) +fn +=(string: String, item: ?) +fn +=(string: String, mut item: ?) +fn +=(timestamp: Instant, seconds: float) +fn +=(string: String, utf8: Blob) +fn +=(map: Map, map2: Map) +``` + +
+
+ +
+ +
+Add the specified number of `seconds` to the timestamp. +
+ +
+
+
+
+

fn -

+ +```rust,ignore +fn -(x: i16) -> i16 +fn -(x: float) -> float +fn -(x: f32) -> f32 +fn -(x: i128) -> i128 +fn -(x: i32) -> i32 +fn -(x: i8) -> i8 +fn -(x: int) -> int +fn -(timestamp: Instant, seconds: int) -> Instant +fn -(x: i32, y: i32) -> i32 +fn -(timestamp1: Instant, timestamp2: Instant) -> ? +fn -(x: u8, y: u8) -> u8 +fn -(x: i128, y: i128) -> i128 +fn -(x: f32, y: int) -> f32 +fn -(x: i16, y: i16) -> i16 +fn -(x: u16, y: u16) -> u16 +fn -(x: u32, y: u32) -> u32 +fn -(x: u128, y: u128) -> u128 +fn -(timestamp: Instant, seconds: float) -> Instant +fn -(x: int, y: f32) -> f32 +fn -(x: u64, y: u64) -> u64 +fn -(x: i8, y: i8) -> i8 +fn -(x: f32, y: f32) -> f32 +``` + +
+
+ +
+ +
+Subtract the specified number of `seconds` from the timestamp and return it as a new timestamp. +
+ +
+
+
+
+

fn -=

+ +```rust,ignore +fn -=(timestamp: Instant, seconds: float) +fn -=(timestamp: Instant, seconds: int) +``` + +
+
+ +
+ +
+Subtract the specified number of `seconds` from the timestamp. +
+ +
+
+
+
+

op <

+ +```rust,ignore +op f32 < int -> bool +op u16 < u16 -> bool +op u32 < u32 -> bool +op i16 < i16 -> bool +op Instant < Instant -> bool +op i32 < i32 -> bool +op i128 < i128 -> bool +op u8 < u8 -> bool +op int < f32 -> bool +op i8 < i8 -> bool +op f32 < f32 -> bool +op u64 < u64 -> bool +op u128 < u128 -> bool +``` + +
+
+ +
+ +
+Return `true` if the first timestamp is earlier than the second. +
+ +
+
+
+
+

op <=

+ +```rust,ignore +op int <= f32 -> bool +op u64 <= u64 -> bool +op i8 <= i8 -> bool +op f32 <= f32 -> bool +op u128 <= u128 -> bool +op f32 <= int -> bool +op i16 <= i16 -> bool +op u16 <= u16 -> bool +op u32 <= u32 -> bool +op i32 <= i32 -> bool +op Instant <= Instant -> bool +op u8 <= u8 -> bool +op i128 <= i128 -> bool +``` + +
+
+ +
+ +
+Return `true` if the first timestamp is earlier than or equals to the second. +
+ +
+
+
+
+

op ==

+ +```rust,ignore +op i32 == i32 -> bool +op Instant == Instant -> bool +op u8 == u8 -> bool +op i128 == i128 -> bool +op f32 == int -> bool +op i16 == i16 -> bool +op u32 == u32 -> bool +op Array == Array -> bool +op u16 == u16 -> bool +op u128 == u128 -> bool +op Map == Map -> bool +op int == f32 -> bool +op u64 == u64 -> bool +op i8 == i8 -> bool +op f32 == f32 -> bool +``` + +
+
+ +
+ +
+Return `true` if two timestamps are equal. +
+ +
+
+
+
+

op >

+ +```rust,ignore +op f32 > int -> bool +op i16 > i16 -> bool +op u16 > u16 -> bool +op u32 > u32 -> bool +op i32 > i32 -> bool +op Instant > Instant -> bool +op u8 > u8 -> bool +op i128 > i128 -> bool +op int > f32 -> bool +op u64 > u64 -> bool +op i8 > i8 -> bool +op f32 > f32 -> bool +op u128 > u128 -> bool +``` + +
+
+ +
+ +
+Return `true` if the first timestamp is later than the second. +
+ +
+
+
+
+

op >=

+ +```rust,ignore +op f32 >= int -> bool +op u16 >= u16 -> bool +op u32 >= u32 -> bool +op i16 >= i16 -> bool +op Instant >= Instant -> bool +op i32 >= i32 -> bool +op i128 >= i128 -> bool +op u8 >= u8 -> bool +op int >= f32 -> bool +op f32 >= f32 -> bool +op i8 >= i8 -> bool +op u64 >= u64 -> bool +op u128 >= u128 -> bool +``` + +
+
+ +
+ +
+Return `true` if the first timestamp is later than or equals to the second. +
+ +
+
+
+
+

get/set ?.tag

+ +```rust,ignore +get ?.tag -> int +set ?.tag = int +``` + +
+
+ + +
+ +
+Return the _tag_ of a `Dynamic` value. +
+ + +
+
+
+
+

get/set Array.is_empty

+ +```rust,ignore +get Array.is_empty -> bool +``` + +
+
+ +
+ +
+Return true if the array is empty. +
+ +
+
+
+
+

get/set Array.len

+ +```rust,ignore +get Array.len -> int +``` + +
+
+ +
+ +
+Number of elements in the array. +
+ +
+
+
+
+

get/set Blob.is_empty

+ +```rust,ignore +get Blob.is_empty -> bool +``` + +
+
+ +
+ +
+Return true if the BLOB is empty. +
+ +
+
+
+
+

get/set Blob.len

+ +```rust,ignore +get Blob.len -> int +``` + +
+
+ + +
+ +
+Return the length of the BLOB. +
+ + +
+
+
+
+

fn E

+ +```rust,ignore +fn E() -> float +``` + +
+
+ +
+ +
+Return the natural number _e_. +
+ +
+
+
+
+

get/set FnPtr.is_anonymous

+ +```rust,ignore +get FnPtr.is_anonymous -> bool +``` + +
+
+ + +
+ +
+Return `true` if the function is an anonymous function. +
+ + +
+
+
+
+

get/set FnPtr.name

+ +```rust,ignore +get FnPtr.name -> String +``` + +
+
+ + +
+ +
+Return the name of the function. +
+ + +
+
+
+
+

get/set Instant.elapsed

+ +```rust,ignore +get Instant.elapsed -> ? +``` + +
+
+ + +
+ +
+Return the number of seconds between the current system time and the timestamp. +
+ + +
+
+
+
+

fn PI

+ +```rust,ignore +fn PI() -> float +``` + +
+
+ +
+ +
+Return the number π. +
+ +
+
+
+
+

get/set Range<int>.end

+ +```rust,ignore +get Range.end -> int +``` + +
+
+ +
+ +
+Return the end of the exclusive range. +
+ +
+
+
+
+

get/set Range<int>.is_empty

+ +```rust,ignore +get Range.is_empty -> bool +``` + +
+
+ +
+ +
+Return true if the range contains no items. +
+ +
+
+
+
+

get/set Range<int>.is_exclusive

+ +```rust,ignore +get Range.is_exclusive -> bool +``` + +
+
+ +
+ +
+Return `true` if the range is exclusive. +
+ +
+
+
+
+

get/set Range<int>.is_inclusive

+ +```rust,ignore +get Range.is_inclusive -> bool +``` + +
+
+ +
+ +
+Return `true` if the range is inclusive. +
+ +
+
+
+
+

get/set Range<int>.start

+ +```rust,ignore +get Range.start -> int +``` + +
+
+ +
+ +
+Return the start of the exclusive range. +
+ +
+
+
+
+

get/set RangeInclusive<int>.end

+ +```rust,ignore +get RangeInclusive.end -> int +``` + +
+
+ +
+ +
+Return the end of the inclusive range. +
+ +
+
+
+
+

get/set RangeInclusive<int>.is_empty

+ +```rust,ignore +get RangeInclusive.is_empty -> bool +``` + +
+
+ +
+ +
+Return true if the range contains no items. +
+ +
+
+
+
+

get/set RangeInclusive<int>.is_exclusive

+ +```rust,ignore +get RangeInclusive.is_exclusive -> bool +``` + +
+
+ +
+ +
+Return `true` if the range is exclusive. +
+ +
+
+
+
+

get/set RangeInclusive<int>.is_inclusive

+ +```rust,ignore +get RangeInclusive.is_inclusive -> bool +``` + +
+
+ +
+ +
+Return `true` if the range is inclusive. +
+ +
+
+
+
+

get/set RangeInclusive<int>.start

+ +```rust,ignore +get RangeInclusive.start -> int +``` + +
+
+ +
+ +
+Return the start of the inclusive range. +
+ +
+
+
+
+

get/set String.bytes

+ +```rust,ignore +get String.bytes -> int +``` + +
+
+ + +
+ +
+Return the length of the string, in number of bytes used to store it in UTF-8 encoding. +
+ + +
+
+
+
+

get/set String.chars

+ +```rust,ignore +get String.chars -> CharsStream +``` + +
+
+ + +
+ +
+Return an iterator over all the characters in the string. +
+ + +
+
+
+
+

get/set String.is_empty

+ +```rust,ignore +get String.is_empty -> bool +``` + +
+
+ +
+ +
+Return true if the string is empty. +
+ +
+
+
+
+

get/set String.len

+ +```rust,ignore +get String.len -> int +``` + +
+
+ + +
+ +
+Return the length of the string, in number of characters. +
+ + +
+
+
+
+

fn abs

+ +```rust,ignore +fn abs(x: f32) -> f32 +fn abs(x: float) -> float +fn abs(x: i16) -> i16 +fn abs(x: int) -> int +fn abs(x: i32) -> i32 +fn abs(x: i8) -> i8 +fn abs(x: i128) -> i128 +``` + +
+
+ +
+ +
+Return the absolute value of the floating-point number. +
+ +
+
+
+
+

fn acos

+ +```rust,ignore +fn acos(x: float) -> float +``` + +
+
+ +
+ +
+Return the arc-cosine of the floating-point number, in radians. +
+ +
+
+
+
+

fn acosh

+ +```rust,ignore +fn acosh(x: float) -> float +``` + +
+
+ +
+ +
+Return the arc-hyperbolic-cosine of the floating-point number, in radians. +
+ +
+
+
+
+

fn all

+ +```rust,ignore +fn all(array: Array, filter: String) -> bool +fn all(array: Array, filter: FnPtr) -> bool +``` + +
+
+ + + + +
+ +
+Return `true` if all elements in the array return `true` when applied a function named by `filter`. +
+ + + + +
+
+
+
+

fn append

+ +```rust,ignore +fn append(blob: Blob, character: char) +fn append(string: String, utf8: Blob) +fn append(blob1: Blob, blob2: Blob) +fn append(blob: Blob, value: int) +fn append(array: Array, new_array: Array) +fn append(blob: Blob, string: String) +fn append(string: String, mut item: ?) +``` + +
+
+ + +
+ +
+Add a character (as UTF-8 encoded byte-stream) to the end of the BLOB +
+ + +
+
+
+
+

fn as_string

+ +```rust,ignore +fn as_string(blob: Blob) -> String +``` + +
+
+ + +
+ +
+Convert the BLOB into a string. + +The byte stream must be valid UTF-8, otherwise an error is raised. +
+ + +
+
+
+
+

fn asin

+ +```rust,ignore +fn asin(x: float) -> float +``` + +
+
+ +
+ +
+Return the arc-sine of the floating-point number, in radians. +
+ +
+
+
+
+

fn asinh

+ +```rust,ignore +fn asinh(x: float) -> float +``` + +
+
+ +
+ +
+Return the arc-hyperbolic-sine of the floating-point number, in radians. +
+ +
+
+
+
+

fn atan

+ +```rust,ignore +fn atan(x: float) -> float +fn atan(x: float, y: float) -> float +``` + +
+
+ +
+ +
+Return the arc-tangent of the floating-point number, in radians. +
+ +
+
+
+
+

fn atanh

+ +```rust,ignore +fn atanh(x: float) -> float +``` + +
+
+ +
+ +
+Return the arc-hyperbolic-tangent of the floating-point number, in radians. +
+ +
+
+
+
+

fn bits

+ +```rust,ignore +fn bits(value: int) -> BitRange +fn bits(value: int, from: int) -> BitRange +fn bits(value: int, range: Range) -> BitRange +fn bits(value: int, range: RangeInclusive) -> BitRange +fn bits(value: int, from: int, len: int) -> BitRange +``` + +
+
+ + +
+ +
+Return an iterator over all the bits in the number. +
+ + +
+
+
+
+

fn blob

+ +```rust,ignore +fn blob() -> Blob +fn blob(len: int) -> Blob +fn blob(len: int, value: int) -> Blob +``` + +
+
+ +
+ +
+Return a new, empty BLOB. +
+ +
+
+
+
+

fn bytes

+ +```rust,ignore +fn bytes(string: String) -> int +``` + +
+
+ + +
+ +
+Return the length of the string, in number of bytes used to store it in UTF-8 encoding. +
+ + +
+
+
+
+

fn ceiling

+ +```rust,ignore +fn ceiling(x: float) -> float +``` + +
+
+ +
+ +
+Return the smallest whole number larger than or equals to the floating-point number. +
+ +
+
+
+
+

fn chars

+ +```rust,ignore +fn chars(string: String) -> CharsStream +fn chars(string: String, range: RangeInclusive) -> CharsStream +fn chars(string: String, range: Range) -> CharsStream +fn chars(string: String, start: int) -> CharsStream +fn chars(string: String, start: int, len: int) -> CharsStream +``` + +
+
+ + +
+ +
+Return an iterator over the characters in the string. +
+ + +
+
+
+
+

fn chop

+ +```rust,ignore +fn chop(array: Array, len: int) +fn chop(blob: Blob, len: int) +``` + +
+
+ + +
+ +
+Cut off the head of the array, leaving a tail of the specified length. + +* If `len` ≤ 0, the array is cleared. +* If `len` ≥ length of array, the array is not modified. +
+ + +
+
+
+
+

fn clear

+ +```rust,ignore +fn clear(string: String) +fn clear(map: Map) +fn clear(blob: Blob) +fn clear(array: Array) +``` + +
+
+ +
+ +
+Clear the string, making it empty. +
+ +
+
+
+
+

fn contains

+ +```rust,ignore +fn contains(range: RangeInclusive, value: int) -> bool +fn contains(array: Array, value: ?) -> bool +fn contains(string: String, character: char) -> bool +fn contains(map: Map, property: String) -> bool +fn contains(string: String, match_string: String) -> bool +fn contains(range: Range, value: int) -> bool +fn contains(blob: Blob, value: int) -> bool +``` + +
+
+ +
+ +
+Return `true` if the range contains a specified value. +
+ +
+
+
+
+

fn cos

+ +```rust,ignore +fn cos(x: float) -> float +``` + +
+
+ +
+ +
+Return the cosine of the floating-point number in radians. +
+ +
+
+
+
+

fn cosh

+ +```rust,ignore +fn cosh(x: float) -> float +``` + +
+
+ +
+ +
+Return the hyperbolic cosine of the floating-point number in radians. +
+ +
+
+
+
+

fn crop

+ +```rust,ignore +fn crop(string: String, range: RangeInclusive) +fn crop(string: String, range: Range) +fn crop(string: String, start: int) +fn crop(string: String, start: int, len: int) +``` + +
+
+ + +
+ +
+Remove all characters from the string except those within an inclusive `range`. +
+ + +
+
+
+
+

fn debug

+ +```rust,ignore +fn debug() -> String +fn debug(number: float) -> String +fn debug(number: f32) -> String +fn debug(unit: ?) -> String +fn debug(character: char) -> String +fn debug(string: String) -> String +fn debug(value: bool) -> String +fn debug(array: Array) -> String +fn debug(f: FnPtr) -> String +fn debug(map: Map) -> String +fn debug(item: ?) -> String +``` + +
+
+ +
+ +
+Return the empty string. +
+ +
+
+
+
+

fn dedup

+ +```rust,ignore +fn dedup(array: Array) +fn dedup(array: Array, comparer: String) +fn dedup(array: Array, comparer: FnPtr) +``` + +
+
+ + +
+ +
+Remove duplicated _consecutive_ elements from the array. + +The operator `==` is used to compare elements and must be defined, +otherwise `false` is assumed. +
+ + +
+
+
+
+

fn drain

+ +```rust,ignore +fn drain(blob: Blob, range: RangeInclusive) -> Blob +fn drain(array: Array, range: Range) -> Array +fn drain(blob: Blob, range: Range) -> Blob +fn drain(array: Array, filter: FnPtr) -> Array +fn drain(map: Map, filter: FnPtr) -> Map +fn drain(array: Array, filter: String) -> Array +fn drain(array: Array, range: RangeInclusive) -> Array +fn drain(blob: Blob, start: int, len: int) -> Blob +fn drain(array: Array, start: int, len: int) -> Array +``` + +
+
+ + +
+ +
+Remove all bytes in the BLOB within an inclusive `range` and return them as a new BLOB. +
+ + +
+
+
+
+

fn elapsed

+ +```rust,ignore +fn elapsed(timestamp: Instant) -> ? +``` + +
+
+ + +
+ +
+Return the number of seconds between the current system time and the timestamp. +
+ + +
+
+
+
+

fn end

+ +```rust,ignore +fn end(range: RangeInclusive) -> int +fn end(range: Range) -> int +``` + +
+
+ +
+ +
+Return the end of the inclusive range. +
+ +
+
+
+
+

fn ends_with

+ +```rust,ignore +fn ends_with(string: String, match_string: String) -> bool +``` + +
+
+ + +
+ +
+Return `true` if the string ends with a specified string. +
+ + +
+
+
+
+

fn exit

+ +```rust,ignore +fn exit() -> ? +fn exit(value: ?) -> ? +``` + +
+
+ + +
+ +
+Exit the script evaluation immediately with `()` as exit value. +
+ + +
+
+
+
+

fn exp

+ +```rust,ignore +fn exp(x: float) -> float +``` + +
+
+ +
+ +
+Return the exponential of the floating-point number. +
+ +
+
+
+
+

fn extract

+ +```rust,ignore +fn extract(blob: Blob, start: int) -> Blob +fn extract(array: Array, start: int) -> Array +fn extract(array: Array, range: RangeInclusive) -> Array +fn extract(blob: Blob, range: Range) -> Blob +fn extract(array: Array, range: Range) -> Array +fn extract(blob: Blob, range: RangeInclusive) -> Blob +fn extract(blob: Blob, start: int, len: int) -> Blob +fn extract(array: Array, start: int, len: int) -> Array +``` + +
+
+ + +
+ +
+Copy a portion of the BLOB beginning at the `start` position till the end and return it as +a new BLOB. + +* If `start` < 0, position counts from the end of the BLOB (`-1` is the last byte). +* If `start` < -length of BLOB, the entire BLOB is copied and returned. +* If `start` ≥ length of BLOB, an empty BLOB is returned. +
+ + +
+
+
+
+

get/set f32.is_zero

+ +```rust,ignore +get f32.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the floating-point number is zero. +
+ +
+
+
+
+

fn fill_with

+ +```rust,ignore +fn fill_with(map: Map, map2: Map) +``` + +
+
+ + +
+ +
+Add all property values of another object map into the object map. +Only properties that do not originally exist in the object map are added. +
+ + +
+
+
+
+

fn filter

+ +```rust,ignore +fn filter(array: Array, filter: FnPtr) -> Array +fn filter(array: Array, filter_func: String) -> Array +fn filter(map: Map, filter: FnPtr) -> Map +``` + +
+
+ + + + +
+ +
+Iterate through all the elements in the array, applying a `filter` function to each element +in turn, and return a copy of all elements (in order) that return `true` as a new array. +
+ + + + +
+
+
+
+

fn find

+ +```rust,ignore +fn find(array: Array, filter: FnPtr) -> ? +fn find(array: Array, filter: FnPtr, start: int) -> ? +``` + +
+
+ + + + +
+ +
+Iterate through all the elements in the array, applying a `filter` function to each element +in turn, and return a copy of the first element that returns `true`. If no element returns +`true`, `()` is returned. +
+ + + + +
+
+
+
+

fn find_map

+ +```rust,ignore +fn find_map(array: Array, filter: FnPtr) -> ? +fn find_map(array: Array, filter: FnPtr, start: int) -> ? +``` + +
+
+ + + + +
+ +
+Iterate through all the elements in the array, applying a `mapper` function to each element +in turn, and return the first result that is not `()`. Otherwise, `()` is returned. +
+ + + + +
+
+
+
+

get/set float.ceiling

+ +```rust,ignore +get float.ceiling -> float +``` + +
+
+ +
+ +
+Return the smallest whole number larger than or equals to the floating-point number. +
+ +
+
+
+
+

get/set float.floor

+ +```rust,ignore +get float.floor -> float +``` + +
+
+ +
+ +
+Return the largest whole number less than or equals to the floating-point number. +
+ +
+
+
+
+

get/set float.fraction

+ +```rust,ignore +get float.fraction -> float +``` + +
+
+ +
+ +
+Return the fractional part of the floating-point number. +
+ +
+
+
+
+

get/set float.int

+ +```rust,ignore +get float.int -> float +``` + +
+
+ +
+ +
+Return the integral part of the floating-point number. +
+ +
+
+
+
+

get/set float.is_finite

+ +```rust,ignore +get float.is_finite -> bool +``` + +
+
+ +
+ +
+Return `true` if the floating-point number is finite. +
+ +
+
+
+
+

get/set float.is_infinite

+ +```rust,ignore +get float.is_infinite -> bool +``` + +
+
+ +
+ +
+Return `true` if the floating-point number is infinite. +
+ +
+
+
+
+

get/set float.is_nan

+ +```rust,ignore +get float.is_nan -> bool +``` + +
+
+ +
+ +
+Return `true` if the floating-point number is `NaN` (Not A Number). +
+ +
+
+
+
+

get/set float.is_zero

+ +```rust,ignore +get float.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the floating-point number is zero. +
+ +
+
+
+
+

get/set float.round

+ +```rust,ignore +get float.round -> float +``` + +
+
+ +
+ +
+Return the nearest whole number closest to the floating-point number. +Rounds away from zero. +
+ +
+
+
+
+

fn floor

+ +```rust,ignore +fn floor(x: float) -> float +``` + +
+
+ +
+ +
+Return the largest whole number less than or equals to the floating-point number. +
+ +
+
+
+
+

fn for_each

+ +```rust,ignore +fn for_each(array: Array, map: FnPtr) +``` + +
+
+ + + +
+ +
+Iterate through all the elements in the array, applying a `process` function to each element in turn. +Each element is bound to `this` before calling the function. +
+ + + +
+
+
+
+

fn fraction

+ +```rust,ignore +fn fraction(x: float) -> float +``` + +
+
+ +
+ +
+Return the fractional part of the floating-point number. +
+ +
+
+
+
+

fn get

+ +```rust,ignore +fn get(blob: Blob, index: int) -> int +fn get(map: Map, property: String) -> ? +fn get(array: Array, index: int) -> ? +fn get(string: String, index: int) -> ? +``` + +
+
+ + +
+ +
+Get the byte value at the `index` position in the BLOB. + +* If `index` < 0, position counts from the end of the BLOB (`-1` is the last element). +* If `index` < -length of BLOB, zero is returned. +* If `index` ≥ length of BLOB, zero is returned. +
+ + +
+
+
+
+

fn get_bit

+ +```rust,ignore +fn get_bit(value: int, bit: int) -> bool +``` + +
+
+ + +
+ +
+Return `true` if the specified `bit` in the number is set. + +If `bit` < 0, position counts from the MSB (Most Significant Bit). +
+ + +
+
+
+
+

fn get_bits

+ +```rust,ignore +fn get_bits(value: int, range: RangeInclusive) -> int +fn get_bits(value: int, range: Range) -> int +fn get_bits(value: int, start: int, bits: int) -> int +``` + +
+
+ + +
+ +
+Return an inclusive range of bits in the number as a new number. +
+ + +
+
+
+
+

fn get_fn_metadata_list

+ +```rust,ignore +fn get_fn_metadata_list() -> Array +fn get_fn_metadata_list(name: String) -> Array +fn get_fn_metadata_list(name: String, params: int) -> Array +``` + +
+
+ +
+ +
+Return an array of object maps containing metadata of all script-defined functions. +
+ +
+
+
+
+

fn hypot

+ +```rust,ignore +fn hypot(x: float, y: float) -> float +``` + +
+
+ +
+ +
+Return the hypotenuse of a triangle with sides `x` and `y`. +
+ +
+
+
+
+

get/set i128.is_even

+ +```rust,ignore +get i128.is_even -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

get/set i128.is_odd

+ +```rust,ignore +get i128.is_odd -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

get/set i128.is_zero

+ +```rust,ignore +get i128.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

get/set i16.is_even

+ +```rust,ignore +get i16.is_even -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

get/set i16.is_odd

+ +```rust,ignore +get i16.is_odd -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

get/set i16.is_zero

+ +```rust,ignore +get i16.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

get/set i32.is_even

+ +```rust,ignore +get i32.is_even -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

get/set i32.is_odd

+ +```rust,ignore +get i32.is_odd -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

get/set i32.is_zero

+ +```rust,ignore +get i32.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

get/set i8.is_even

+ +```rust,ignore +get i8.is_even -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

get/set i8.is_odd

+ +```rust,ignore +get i8.is_odd -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

get/set i8.is_zero

+ +```rust,ignore +get i8.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

fn index_of

+ +```rust,ignore +fn index_of(array: Array, filter: String) -> int +fn index_of(string: String, character: char) -> int +fn index_of(string: String, find_string: String) -> int +fn index_of(array: Array, value: ?) -> int +fn index_of(array: Array, filter: FnPtr) -> int +fn index_of(string: String, find_string: String, start: int) -> int +fn index_of(array: Array, filter: String, start: int) -> int +fn index_of(array: Array, filter: FnPtr, start: int) -> int +fn index_of(string: String, character: char, start: int) -> int +fn index_of(array: Array, value: ?, start: int) -> int +``` + +
+
+ + + + +
+ +
+Iterate through all the elements in the array, applying a function named by `filter` to each +element in turn, and return the index of the first element that returns `true`. +If no element returns `true`, `-1` is returned. +
+ + + + +
+
+
+
+

fn insert

+ +```rust,ignore +fn insert(blob: Blob, index: int, value: int) +fn insert(array: Array, index: int, item: ?) +``` + +
+
+ + +
+ +
+Add a byte `value` to the BLOB at a particular `index` position. + +* If `index` < 0, position counts from the end of the BLOB (`-1` is the last byte). +* If `index` < -length of BLOB, the byte value is added to the beginning of the BLOB. +* If `index` ≥ length of BLOB, the byte value is appended to the end of the BLOB. + +Only the lower 8 bits of the `value` are used; all other bits are ignored. +
+ + +
+
+
+
+

fn int

+ +```rust,ignore +fn int(x: float) -> float +``` + +
+
+ +
+ +
+Return the integral part of the floating-point number. +
+ +
+
+
+
+

get/set int.bits

+ +```rust,ignore +get int.bits -> BitRange +``` + +
+
+ + +
+ +
+Return an iterator over all the bits in the number. +
+ + +
+
+
+
+

get/set int.is_even

+ +```rust,ignore +get int.is_even -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

get/set int.is_odd

+ +```rust,ignore +get int.is_odd -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

get/set int.is_zero

+ +```rust,ignore +get int.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

fn is_anonymous

+ +```rust,ignore +fn is_anonymous(fn_ptr: FnPtr) -> bool +``` + +
+
+ + +
+ +
+Return `true` if the function is an anonymous function. +
+ + +
+
+
+
+

fn is_empty

+ +```rust,ignore +fn is_empty(blob: Blob) -> bool +fn is_empty(array: Array) -> bool +fn is_empty(map: Map) -> bool +fn is_empty(range: Range) -> bool +fn is_empty(string: String) -> bool +fn is_empty(range: RangeInclusive) -> bool +``` + +
+
+ +
+ +
+Return true if the BLOB is empty. +
+ +
+
+
+
+

fn is_even

+ +```rust,ignore +fn is_even(x: u128) -> bool +fn is_even(x: u16) -> bool +fn is_even(x: u64) -> bool +fn is_even(x: i16) -> bool +fn is_even(x: int) -> bool +fn is_even(x: u32) -> bool +fn is_even(x: u8) -> bool +fn is_even(x: i128) -> bool +fn is_even(x: i32) -> bool +fn is_even(x: i8) -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

fn is_exclusive

+ +```rust,ignore +fn is_exclusive(range: RangeInclusive) -> bool +fn is_exclusive(range: Range) -> bool +``` + +
+
+ +
+ +
+Return `true` if the range is exclusive. +
+ +
+
+
+
+

fn is_finite

+ +```rust,ignore +fn is_finite(x: float) -> bool +``` + +
+
+ +
+ +
+Return `true` if the floating-point number is finite. +
+ +
+
+
+
+

fn is_inclusive

+ +```rust,ignore +fn is_inclusive(range: Range) -> bool +fn is_inclusive(range: RangeInclusive) -> bool +``` + +
+
+ +
+ +
+Return `true` if the range is inclusive. +
+ +
+
+
+
+

fn is_infinite

+ +```rust,ignore +fn is_infinite(x: float) -> bool +``` + +
+
+ +
+ +
+Return `true` if the floating-point number is infinite. +
+ +
+
+
+
+

fn is_nan

+ +```rust,ignore +fn is_nan(x: float) -> bool +``` + +
+
+ +
+ +
+Return `true` if the floating-point number is `NaN` (Not A Number). +
+ +
+
+
+
+

fn is_odd

+ +```rust,ignore +fn is_odd(x: u64) -> bool +fn is_odd(x: i16) -> bool +fn is_odd(x: u16) -> bool +fn is_odd(x: u128) -> bool +fn is_odd(x: i32) -> bool +fn is_odd(x: i8) -> bool +fn is_odd(x: i128) -> bool +fn is_odd(x: u32) -> bool +fn is_odd(x: u8) -> bool +fn is_odd(x: int) -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

fn is_zero

+ +```rust,ignore +fn is_zero(x: i32) -> bool +fn is_zero(x: i8) -> bool +fn is_zero(x: i128) -> bool +fn is_zero(x: int) -> bool +fn is_zero(x: u8) -> bool +fn is_zero(x: u32) -> bool +fn is_zero(x: i16) -> bool +fn is_zero(x: u64) -> bool +fn is_zero(x: u16) -> bool +fn is_zero(x: f32) -> bool +fn is_zero(x: float) -> bool +fn is_zero(x: u128) -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

fn keys

+ +```rust,ignore +fn keys(map: Map) -> Array +``` + +
+
+ + +
+ +
+Return an array with all the property names in the object map. +
+ + +
+
+
+
+

fn len

+ +```rust,ignore +fn len(blob: Blob) -> int +fn len(array: Array) -> int +fn len(map: Map) -> int +fn len(string: String) -> int +``` + +
+
+ + +
+ +
+Return the length of the BLOB. +
+ + +
+
+
+
+

fn ln

+ +```rust,ignore +fn ln(x: float) -> float +``` + +
+
+ +
+ +
+Return the natural log of the floating-point number. +
+ +
+
+
+
+

fn log

+ +```rust,ignore +fn log(x: float) -> float +fn log(x: float, base: float) -> float +``` + +
+
+ +
+ +
+Return the log of the floating-point number with base 10. +
+ +
+
+
+
+

fn make_lower

+ +```rust,ignore +fn make_lower(string: String) +fn make_lower(character: char) +``` + +
+
+ + +
+ +
+Convert the string to all lower-case. +
+ + +
+
+
+
+

fn make_upper

+ +```rust,ignore +fn make_upper(string: String) +fn make_upper(character: char) +``` + +
+
+ + +
+ +
+Convert the string to all upper-case. +
+ + +
+
+
+
+

fn map

+ +```rust,ignore +fn map(array: Array, mapper: String) -> Array +fn map(array: Array, map: FnPtr) -> Array +``` + +
+
+ + + + +
+ +
+Iterate through all the elements in the array, applying a function named by `mapper` to each +element in turn, and return the results as a new array. +
+ + + + +
+
+
+
+

fn max

+ +```rust,ignore +fn max(x: i8, y: i8) -> i8 +fn max(x: f32, y: f32) -> f32 +fn max(x: u64, y: u64) -> u64 +fn max(x: int, y: f32) -> f32 +fn max(x: int, y: float) -> float +fn max(x: f32, y: float) -> float +fn max(x: u128, y: u128) -> u128 +fn max(x: float, y: int) -> float +fn max(x: u16, y: u16) -> u16 +fn max(char1: char, char2: char) -> char +fn max(x: u32, y: u32) -> u32 +fn max(x: i16, y: i16) -> i16 +fn max(x: f32, y: int) -> f32 +fn max(x: i128, y: i128) -> i128 +fn max(x: float, y: float) -> float +fn max(string1: String, string2: String) -> String +fn max(x: u8, y: u8) -> u8 +fn max(x: int, y: int) -> int +fn max(x: float, y: f32) -> float +fn max(x: i32, y: i32) -> i32 +``` + +
+
+ + +
+ +
+Return the character that is lexically greater than the other character. +
+ + +
+
+
+
+

fn min

+ +```rust,ignore +fn min(x: u64, y: u64) -> u64 +fn min(x: i8, y: i8) -> i8 +fn min(x: f32, y: f32) -> f32 +fn min(x: int, y: float) -> float +fn min(x: f32, y: float) -> float +fn min(x: int, y: f32) -> f32 +fn min(x: float, y: int) -> float +fn min(x: u128, y: u128) -> u128 +fn min(x: i16, y: i16) -> i16 +fn min(char1: char, char2: char) -> char +fn min(x: u32, y: u32) -> u32 +fn min(x: u16, y: u16) -> u16 +fn min(x: f32, y: int) -> f32 +fn min(x: u8, y: u8) -> u8 +fn min(x: i128, y: i128) -> i128 +fn min(x: float, y: float) -> float +fn min(string1: String, string2: String) -> String +fn min(x: i32, y: i32) -> i32 +fn min(x: float, y: f32) -> float +fn min(x: int, y: int) -> int +``` + +
+
+ + +
+ +
+Return the character that is lexically smaller than the other character. +
+ + +
+
+
+
+

fn mixin

+ +```rust,ignore +fn mixin(map: Map, map2: Map) +``` + +
+
+ + +
+ +
+Add all property values of another object map into the object map. +Existing property values of the same names are replaced. +
+ + +
+
+
+
+

fn name

+ +```rust,ignore +fn name(fn_ptr: FnPtr) -> String +``` + +
+
+ + +
+ +
+Return the name of the function. +
+ + +
+
+
+
+

fn pad

+ +```rust,ignore +fn pad(array: Array, len: int, item: ?) +fn pad(string: String, len: int, padding: String) +fn pad(blob: Blob, len: int, value: int) +fn pad(string: String, len: int, character: char) +``` + +
+
+ + +
+ +
+Pad the array to at least the specified length with copies of a specified element. + +If `len` ≤ length of array, no padding is done. +
+ + +
+
+
+
+

fn parse_be_float

+ +```rust,ignore +fn parse_be_float(blob: Blob, range: RangeInclusive) -> float +fn parse_be_float(blob: Blob, range: Range) -> float +fn parse_be_float(blob: Blob, start: int, len: int) -> float +``` + +
+
+ +
+ +
+Parse the bytes within an inclusive `range` in the BLOB as a `FLOAT` +in big-endian byte order. + +* If number of bytes in `range` < number of bytes for `FLOAT`, zeros are padded. +* If number of bytes in `range` > number of bytes for `FLOAT`, extra bytes are ignored. +
+ +
+
+
+
+

fn parse_be_int

+ +```rust,ignore +fn parse_be_int(blob: Blob, range: RangeInclusive) -> int +fn parse_be_int(blob: Blob, range: Range) -> int +fn parse_be_int(blob: Blob, start: int, len: int) -> int +``` + +
+
+ +
+ +
+Parse the bytes within an inclusive `range` in the BLOB as an `INT` +in big-endian byte order. + +* If number of bytes in `range` < number of bytes for `INT`, zeros are padded. +* If number of bytes in `range` > number of bytes for `INT`, extra bytes are ignored. + +```rhai +let b = blob(); + +b += 1; b += 2; b += 3; b += 4; b += 5; + +let x = b.parse_be_int(1..=3); // parse three bytes + +print(x.to_hex()); // prints "0203040000...00" +``` +
+ +
+
+
+
+

fn parse_float

+ +```rust,ignore +fn parse_float(string: String) -> float +``` + +
+
+ + +
+ +
+Parse a string into a floating-point number. +
+ + +
+
+
+
+

fn parse_int

+ +```rust,ignore +fn parse_int(string: String) -> int +fn parse_int(string: String, radix: int) -> int +``` + +
+
+ + +
+ +
+Parse a string into an integer number. +
+ + +
+
+
+
+

fn parse_json

+ +```rust,ignore +fn parse_json(json: String) -> ? +``` + +
+
+ + +
+ +
+Parse a JSON string into a value. +
+ + +
+
+
+
+

fn parse_le_float

+ +```rust,ignore +fn parse_le_float(blob: Blob, range: Range) -> float +fn parse_le_float(blob: Blob, range: RangeInclusive) -> float +fn parse_le_float(blob: Blob, start: int, len: int) -> float +``` + +
+
+ +
+ +
+Parse the bytes within an exclusive `range` in the BLOB as a `FLOAT` +in little-endian byte order. + +* If number of bytes in `range` < number of bytes for `FLOAT`, zeros are padded. +* If number of bytes in `range` > number of bytes for `FLOAT`, extra bytes are ignored. +
+ +
+
+
+
+

fn parse_le_int

+ +```rust,ignore +fn parse_le_int(blob: Blob, range: Range) -> int +fn parse_le_int(blob: Blob, range: RangeInclusive) -> int +fn parse_le_int(blob: Blob, start: int, len: int) -> int +``` + +
+
+ +
+ +
+Parse the bytes within an exclusive `range` in the BLOB as an `INT` +in little-endian byte order. + +* If number of bytes in `range` < number of bytes for `INT`, zeros are padded. +* If number of bytes in `range` > number of bytes for `INT`, extra bytes are ignored. + +```rhai +let b = blob(); + +b += 1; b += 2; b += 3; b += 4; b += 5; + +let x = b.parse_le_int(1..3); // parse two bytes + +print(x.to_hex()); // prints "0302" +``` +
+ +
+
+
+
+

fn pop

+ +```rust,ignore +fn pop(string: String) -> ? +fn pop(blob: Blob) -> int +fn pop(array: Array) -> ? +fn pop(string: String, len: int) -> String +``` + +
+
+ + +
+ +
+Remove the last character from the string and return it. + +If the string is empty, `()` is returned. +
+ + +
+
+
+
+

fn print

+ +```rust,ignore +fn print() -> String +fn print(array: Array) -> String +fn print(value: bool) -> String +fn print(item: ?) -> String +fn print(map: Map) -> String +fn print(number: float) -> String +fn print(number: f32) -> String +fn print(character: char) -> String +fn print(unit: ?) -> String +fn print(string: String) -> String +``` + +
+
+ +
+ + + +
+
+
+
+

fn push

+ +```rust,ignore +fn push(array: Array, item: ?) +fn push(blob: Blob, value: int) +``` + +
+
+ + +
+ +
+Add a new element, which is not another array, to the end of the array. + +If `item` is `Array`, then `append` is more specific and will be called instead. +
+ + +
+
+
+
+

fn range

+ +```rust,ignore +fn range(from: u128, to: u128) -> Range +fn range(range: Range, step: i16) -> StepRange +fn range(range: Range, step: u16) -> StepRange +fn range(range: Range, step: float) -> StepRange +fn range(range: Range, step: u64) -> StepRange +fn range(range: Range, step: u128) -> StepRange +fn range(from: u64, to: u64) -> Range +fn range(range: Range, step: i32) -> StepRange +fn range(from: i8, to: i8) -> Range +fn range(from: i32, to: i32) -> Range +fn range(from: int, to: int) -> Range +fn range(range: Range, step: i8) -> StepRange +fn range(from: u8, to: u8) -> Range +fn range(range: Range, step: i128) -> StepRange +fn range(range: Range, step: int) -> StepRange +fn range(from: i128, to: i128) -> Range +fn range(range: Range, step: u8) -> StepRange +fn range(from: i16, to: i16) -> Range +fn range(range: Range, step: u32) -> StepRange +fn range(from: u32, to: u32) -> Range +fn range(from: u16, to: u16) -> Range +fn range(from: u64, to: u64, step: u64) -> StepRange +fn range(from: i32, to: i32, step: i32) -> StepRange +fn range(from: float, to: float, step: float) -> StepRange +fn range(from: i8, to: i8, step: i8) -> StepRange +fn range(from: u16, to: u16, step: u16) -> StepRange +fn range(from: u128, to: u128, step: u128) -> StepRange +fn range(from: i16, to: i16, step: i16) -> StepRange +fn range(from: u8, to: u8, step: u8) -> StepRange +fn range(from: i128, to: i128, step: i128) -> StepRange +fn range(from: int, to: int, step: int) -> StepRange +fn range(from: u32, to: u32, step: u32) -> StepRange +``` + +
+
+ + +
+ +
+Return an iterator over the exclusive range of `from..to`. +The value `to` is never included. +
+ + +
+
+
+
+

fn reduce

+ +```rust,ignore +fn reduce(array: Array, reducer: FnPtr) -> ? +fn reduce(array: Array, reducer: String) -> ? +fn reduce(array: Array, reducer: FnPtr, initial: ?) -> ? +fn reduce(array: Array, reducer: String, initial: ?) -> ? +``` + +
+
+ + + +
+ +
+Reduce an array by iterating through all elements while applying the `reducer` function. +
+ + + +
+
+
+
+

fn reduce_rev

+ +```rust,ignore +fn reduce_rev(array: Array, reducer: String) -> ? +fn reduce_rev(array: Array, reducer: FnPtr) -> ? +fn reduce_rev(array: Array, reducer: String, initial: ?) -> ? +fn reduce_rev(array: Array, reducer: FnPtr, initial: ?) -> ? +``` + +
+
+ + + + +
+ +
+Reduce an array by iterating through all elements, in _reverse_ order, +while applying a function named by `reducer`. +
+ + + + +
+
+
+
+

fn remove

+ +```rust,ignore +fn remove(string: String, sub_string: String) +fn remove(blob: Blob, index: int) -> int +fn remove(map: Map, property: String) -> ? +fn remove(array: Array, index: int) -> ? +fn remove(string: String, character: char) +``` + +
+
+ + +
+ +
+Remove all occurrences of a sub-string from the string. +
+ + +
+
+
+
+

fn replace

+ +```rust,ignore +fn replace(string: String, find_string: String, substitute_string: String) +fn replace(string: String, find_character: char, substitute_string: String) +fn replace(string: String, find_character: char, substitute_character: char) +fn replace(string: String, find_string: String, substitute_character: char) +``` + +
+
+ + +
+ +
+Replace all occurrences of the specified sub-string in the string with another string. +
+ + +
+
+
+
+

fn retain

+ +```rust,ignore +fn retain(array: Array, range: RangeInclusive) -> Array +fn retain(array: Array, filter: String) -> Array +fn retain(map: Map, filter: FnPtr) -> Map +fn retain(blob: Blob, range: Range) -> Blob +fn retain(array: Array, filter: FnPtr) -> Array +fn retain(array: Array, range: Range) -> Array +fn retain(blob: Blob, range: RangeInclusive) -> Blob +fn retain(blob: Blob, start: int, len: int) -> Blob +fn retain(array: Array, start: int, len: int) -> Array +``` + +
+
+ + +
+ +
+Remove all elements in the array not within an inclusive `range` and return them as a new array. +
+ + +
+
+
+
+

fn reverse

+ +```rust,ignore +fn reverse(blob: Blob) +fn reverse(array: Array) +``` + +
+
+ + +
+ +
+Reverse the BLOB. +
+ + +
+
+
+
+

fn round

+ +```rust,ignore +fn round(x: float) -> float +``` + +
+
+ +
+ +
+Return the nearest whole number closest to the floating-point number. +Rounds away from zero. +
+ +
+
+
+
+

fn set

+ +```rust,ignore +fn set(string: String, index: int, character: char) +fn set(blob: Blob, index: int, value: int) +fn set(array: Array, index: int, value: ?) +fn set(map: Map, property: String, value: ?) +``` + +
+
+ + +
+ +
+Set the `index` position in the string to a new `character`. + +* If `index` < 0, position counts from the end of the string (`-1` is the last character). +* If `index` < -length of string, the string is not modified. +* If `index` ≥ length of string, the string is not modified. +
+ + +
+
+
+
+

fn set_bit

+ +```rust,ignore +fn set_bit(value: int, bit: int, new_value: bool) +``` + +
+
+ + +
+ +
+Set the specified `bit` in the number if the new value is `true`. +Clear the `bit` if the new value is `false`. + +If `bit` < 0, position counts from the MSB (Most Significant Bit). +
+ + +
+
+
+
+

fn set_bits

+ +```rust,ignore +fn set_bits(value: int, range: RangeInclusive, new_value: int) +fn set_bits(value: int, range: Range, new_value: int) +fn set_bits(value: int, bit: int, bits: int, new_value: int) +``` + +
+
+ + +
+ +
+Replace an inclusive range of bits in the number with a new value. +
+ + +
+
+
+
+

fn set_tag

+ +```rust,ignore +fn set_tag(value: ?, tag: int) +``` + +
+
+ + +
+ +
+Set the _tag_ of a `Dynamic` value. +
+ + +
+
+
+
+

fn shift

+ +```rust,ignore +fn shift(array: Array) -> ? +fn shift(blob: Blob) -> int +``` + +
+
+ + +
+ +
+Remove the first element from the array and return it. + +If the array is empty, `()` is returned. +
+ + +
+
+
+
+

fn sign

+ +```rust,ignore +fn sign(x: f32) -> int +fn sign(x: float) -> int +fn sign(x: i16) -> int +fn sign(x: int) -> int +fn sign(x: i32) -> int +fn sign(x: i8) -> int +fn sign(x: i128) -> int +``` + +
+
+ +
+ +
+Return the sign (as an integer) of the floating-point number according to the following: + +* `0` if the number is zero +* `1` if the number is positive +* `-1` if the number is negative +
+ +
+
+
+
+

fn sin

+ +```rust,ignore +fn sin(x: float) -> float +``` + +
+
+ +
+ +
+Return the sine of the floating-point number in radians. +
+ +
+
+
+
+

fn sinh

+ +```rust,ignore +fn sinh(x: float) -> float +``` + +
+
+ +
+ +
+Return the hyperbolic sine of the floating-point number in radians. +
+ +
+
+
+
+

fn sleep

+ +```rust,ignore +fn sleep(seconds: int) +fn sleep(seconds: float) +``` + +
+
+ + +
+ +
+Block the current thread for a particular number of `seconds`. +
+ + +
+
+
+
+

fn some

+ +```rust,ignore +fn some(array: Array, filter: FnPtr) -> bool +fn some(array: Array, filter: String) -> bool +``` + +
+
+ + + + +
+ +
+Return `true` if any element in the array that returns `true` when applied the `filter` function. +
+ + + + +
+
+
+
+

fn sort

+ +```rust,ignore +fn sort(array: Array) +fn sort(array: Array, comparer: FnPtr) +fn sort(array: Array, comparer: String) +``` + +
+
+ + + +
+ +
+Sort the array. + +All elements in the array must be of the same data type. +
+ + + +
+
+
+
+

fn splice

+ +```rust,ignore +fn splice(blob: Blob, range: RangeInclusive, replace: Blob) +fn splice(array: Array, range: Range, replace: Array) +fn splice(array: Array, range: RangeInclusive, replace: Array) +fn splice(blob: Blob, range: Range, replace: Blob) +fn splice(blob: Blob, start: int, len: int, replace: Blob) +fn splice(array: Array, start: int, len: int, replace: Array) +``` + +
+
+ + +
+ +
+Replace an inclusive `range` of the BLOB with another BLOB. +
+ + +
+
+
+
+

fn split

+ +```rust,ignore +fn split(string: String) -> Array +fn split(string: String, index: int) -> Array +fn split(blob: Blob, index: int) -> Blob +fn split(string: String, delimiter: String) -> Array +fn split(array: Array, index: int) -> Array +fn split(string: String, delimiter: char) -> Array +fn split(string: String, delimiter: char, segments: int) -> Array +fn split(string: String, delimiter: String, segments: int) -> Array +``` + +
+
+ + +
+ +
+Split the string into segments based on whitespaces, returning an array of the segments. +
+ + +
+
+
+
+

fn split_rev

+ +```rust,ignore +fn split_rev(string: String, delimiter: char) -> Array +fn split_rev(string: String, delimiter: String) -> Array +fn split_rev(string: String, delimiter: char, segments: int) -> Array +fn split_rev(string: String, delimiter: String, segments: int) -> Array +``` + +
+
+ + +
+ +
+Split the string into segments based on a `delimiter` character, returning an array of +the segments in _reverse_ order. +
+ + +
+
+
+
+

fn sqrt

+ +```rust,ignore +fn sqrt(x: float) -> float +``` + +
+
+ +
+ +
+Return the square root of the floating-point number. +
+ +
+
+
+
+

fn start

+ +```rust,ignore +fn start(range: RangeInclusive) -> int +fn start(range: Range) -> int +``` + +
+
+ +
+ +
+Return the start of the inclusive range. +
+ +
+
+
+
+

fn starts_with

+ +```rust,ignore +fn starts_with(string: String, match_string: String) -> bool +``` + +
+
+ + +
+ +
+Return `true` if the string starts with a specified string. +
+ + +
+
+
+
+

fn sub_string

+ +```rust,ignore +fn sub_string(string: String, range: RangeInclusive) -> String +fn sub_string(string: String, start: int) -> String +fn sub_string(string: String, range: Range) -> String +fn sub_string(string: String, start: int, len: int) -> String +``` + +
+
+ + +
+ +
+Copy an inclusive range of characters from the string and return it as a new string. +
+ + +
+
+
+
+

fn tag

+ +```rust,ignore +fn tag(value: ?) -> int +``` + +
+
+ + +
+ +
+Return the _tag_ of a `Dynamic` value. +
+ + +
+
+
+
+

fn take

+ +```rust,ignore +fn take(value: ?) -> ? +``` + +
+
+ + +
+ +
+Take ownership of the data in a `Dynamic` value and return it. +The data is _NOT_ cloned. + +The original value is replaced with `()`. +
+ + +
+
+
+
+

fn tan

+ +```rust,ignore +fn tan(x: float) -> float +``` + +
+
+ +
+ +
+Return the tangent of the floating-point number in radians. +
+ +
+
+
+
+

fn tanh

+ +```rust,ignore +fn tanh(x: float) -> float +``` + +
+
+ +
+ +
+Return the hyperbolic tangent of the floating-point number in radians. +
+ +
+
+
+
+

fn timestamp

+ +```rust,ignore +fn timestamp() -> Instant +``` + +
+
+ + +
+ +
+Create a timestamp containing the current system time. +
+ + +
+
+
+
+

fn to_array

+ +```rust,ignore +fn to_array(blob: Blob) -> Array +``` + +
+
+ + +
+ +
+Convert the BLOB into an array of integers. +
+ + +
+
+
+
+

fn to_binary

+ +```rust,ignore +fn to_binary(value: u64) -> String +fn to_binary(value: i16) -> String +fn to_binary(value: u128) -> String +fn to_binary(value: u16) -> String +fn to_binary(value: i128) -> String +fn to_binary(value: i8) -> String +fn to_binary(value: i32) -> String +fn to_binary(value: int) -> String +fn to_binary(value: u8) -> String +fn to_binary(value: u32) -> String +``` + +
+
+ +
+ +
+Convert the `value` into a string in binary format. +
+ +
+
+
+
+

fn to_blob

+ +```rust,ignore +fn to_blob(string: String) -> Blob +``` + +
+
+ + +
+ +
+Convert the string into an UTF-8 encoded byte-stream as a BLOB. +
+ + +
+
+
+
+

fn to_chars

+ +```rust,ignore +fn to_chars(string: String) -> Array +``` + +
+
+ + +
+ +
+Return an array containing all the characters of the string. +
+ + +
+
+
+
+

fn to_debug

+ +```rust,ignore +fn to_debug(value: bool) -> String +fn to_debug(array: Array) -> String +fn to_debug(f: FnPtr) -> String +fn to_debug(map: Map) -> String +fn to_debug(item: ?) -> String +fn to_debug(number: float) -> String +fn to_debug(number: f32) -> String +fn to_debug(character: char) -> String +fn to_debug(unit: ?) -> String +fn to_debug(string: String) -> String +``` + +
+
+ +
+ +
+Convert the boolean value into a string in debug format. +
+ +
+
+
+
+

fn to_degrees

+ +```rust,ignore +fn to_degrees(x: float) -> float +``` + +
+
+ +
+ +
+Convert radians to degrees. +
+ +
+
+
+
+

fn to_float

+ +```rust,ignore +fn to_float() +fn to_float() +fn to_float(x: f32) -> float +fn to_float() +fn to_float() +fn to_float() +fn to_float() +fn to_float() +fn to_float() +fn to_float() +fn to_float() +fn to_float() +``` + +
+
+ +
+ +
+Convert the 32-bit floating-point number to 64-bit. +
+ +
+
+
+
+

fn to_hex

+ +```rust,ignore +fn to_hex(value: u64) -> String +fn to_hex(value: i16) -> String +fn to_hex(value: u16) -> String +fn to_hex(value: u128) -> String +fn to_hex(value: i32) -> String +fn to_hex(value: i8) -> String +fn to_hex(value: i128) -> String +fn to_hex(value: u32) -> String +fn to_hex(value: u8) -> String +fn to_hex(value: int) -> String +``` + +
+
+ +
+ +
+Convert the `value` into a string in hex format. +
+ +
+
+
+
+

fn to_int

+ +```rust,ignore +fn to_int() +fn to_int(x: f32) -> int +fn to_int(x: float) -> int +fn to_int() +fn to_int() +fn to_int() +fn to_int() +fn to_int() +fn to_int() +fn to_int() +fn to_int() +fn to_int() +fn to_int() +``` + +
+
+ +
+ +
+Convert the floating-point number into an integer. +
+ +
+
+
+
+

fn to_json

+ +```rust,ignore +fn to_json(map: Map) -> String +``` + +
+
+ + + + +
+ +
+Return the JSON representation of the object map. +
+ + + + +
+
+
+
+

fn to_lower

+ +```rust,ignore +fn to_lower(string: String) -> String +fn to_lower(character: char) -> char +``` + +
+
+ + +
+ +
+Convert the string to all lower-case and return it as a new string. +
+ + +
+
+
+
+

fn to_octal

+ +```rust,ignore +fn to_octal(value: i32) -> String +fn to_octal(value: i8) -> String +fn to_octal(value: i128) -> String +fn to_octal(value: u32) -> String +fn to_octal(value: u8) -> String +fn to_octal(value: int) -> String +fn to_octal(value: u64) -> String +fn to_octal(value: i16) -> String +fn to_octal(value: u16) -> String +fn to_octal(value: u128) -> String +``` + +
+
+ +
+ +
+Convert the `value` into a string in octal format. +
+ +
+
+
+
+

fn to_radians

+ +```rust,ignore +fn to_radians(x: float) -> float +``` + +
+
+ +
+ +
+Convert degrees to radians. +
+ +
+
+
+
+

fn to_string

+ +```rust,ignore +fn to_string(value: bool) -> String +fn to_string(array: Array) -> String +fn to_string(map: Map) -> String +fn to_string(item: ?) -> String +fn to_string(number: f32) -> String +fn to_string(number: float) -> String +fn to_string(string: String) -> String +fn to_string(character: char) -> String +fn to_string(unit: ?) -> String +``` + +
+
+ +
+ +
+Return the boolean value into a string. +
+ +
+
+
+
+

fn to_upper

+ +```rust,ignore +fn to_upper(character: char) -> char +fn to_upper(string: String) -> String +``` + +
+
+ + +
+ +
+Convert the character to upper-case and return it as a new character. +
+ + +
+
+
+
+

fn trim

+ +```rust,ignore +fn trim(string: String) +``` + +
+
+ + +
+ +
+Remove whitespace characters from both ends of the string. +
+ + +
+
+
+
+

fn truncate

+ +```rust,ignore +fn truncate(array: Array, len: int) +fn truncate(blob: Blob, len: int) +fn truncate(string: String, len: int) +``` + +
+
+ + +
+ +
+Cut off the array at the specified length. + +* If `len` ≤ 0, the array is cleared. +* If `len` ≥ length of array, the array is not truncated. +
+ + +
+
+
+
+

get/set u128.is_even

+ +```rust,ignore +get u128.is_even -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

get/set u128.is_odd

+ +```rust,ignore +get u128.is_odd -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

get/set u128.is_zero

+ +```rust,ignore +get u128.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

get/set u16.is_even

+ +```rust,ignore +get u16.is_even -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

get/set u16.is_odd

+ +```rust,ignore +get u16.is_odd -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

get/set u16.is_zero

+ +```rust,ignore +get u16.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

get/set u32.is_even

+ +```rust,ignore +get u32.is_even -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

get/set u32.is_odd

+ +```rust,ignore +get u32.is_odd -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

get/set u32.is_zero

+ +```rust,ignore +get u32.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

get/set u64.is_even

+ +```rust,ignore +get u64.is_even -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

get/set u64.is_odd

+ +```rust,ignore +get u64.is_odd -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

get/set u64.is_zero

+ +```rust,ignore +get u64.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

get/set u8.is_even

+ +```rust,ignore +get u8.is_even -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

get/set u8.is_odd

+ +```rust,ignore +get u8.is_odd -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

get/set u8.is_zero

+ +```rust,ignore +get u8.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

fn values

+ +```rust,ignore +fn values(map: Map) -> Array +``` + +
+
+ + +
+ +
+Return an array with all the property values in the object map. +
+ + +
+
+
+
+

fn write_ascii

+ +```rust,ignore +fn write_ascii(blob: Blob, range: Range, string: String) +fn write_ascii(blob: Blob, range: RangeInclusive, string: String) +fn write_ascii(blob: Blob, start: int, len: int, string: String) +``` + +
+
+ +
+ +
+Write an ASCII string to the bytes within an exclusive `range` in the BLOB. + +Each ASCII character encodes to one single byte in the BLOB. +Non-ASCII characters are ignored. + +* If number of bytes in `range` < length of `string`, extra bytes in `string` are not written. +* If number of bytes in `range` > length of `string`, extra bytes in `range` are not modified. + +```rhai +let b = blob(8); + +b.write_ascii(1..5, "hello, world!"); + +print(b); // prints "[0068656c6c000000]" +``` +
+ +
+
+
+
+

fn write_be

+ +```rust,ignore +fn write_be(blob: Blob, range: RangeInclusive, value: int) +fn write_be(blob: Blob, range: Range, value: int) +fn write_be(blob: Blob, range: Range, value: float) +fn write_be(blob: Blob, range: RangeInclusive, value: float) +fn write_be(blob: Blob, start: int, len: int, value: float) +fn write_be(blob: Blob, start: int, len: int, value: int) +``` + +
+
+ +
+ +
+Write an `INT` value to the bytes within an inclusive `range` in the BLOB +in big-endian byte order. + +* If number of bytes in `range` < number of bytes for `INT`, extra bytes in `INT` are not written. +* If number of bytes in `range` > number of bytes for `INT`, extra bytes in `range` are not modified. + +```rhai +let b = blob(8, 0x42); + +b.write_be_int(1..=3, 0x99); + +print(b); // prints "[4200000042424242]" +``` +
+ +
+
+
+
+

fn write_le

+ +```rust,ignore +fn write_le(blob: Blob, range: Range, value: float) +fn write_le(blob: Blob, range: RangeInclusive, value: int) +fn write_le(blob: Blob, range: Range, value: int) +fn write_le(blob: Blob, range: RangeInclusive, value: float) +fn write_le(blob: Blob, start: int, len: int, value: float) +fn write_le(blob: Blob, start: int, len: int, value: int) +``` + +
+
+ +
+ +
+Write a `FLOAT` value to the bytes within an exclusive `range` in the BLOB +in little-endian byte order. + +* If number of bytes in `range` < number of bytes for `FLOAT`, extra bytes in `FLOAT` are not written. +* If number of bytes in `range` > number of bytes for `FLOAT`, extra bytes in `range` are not modified. +
+ +
+
+
+
+

fn write_utf8

+ +```rust,ignore +fn write_utf8(blob: Blob, range: Range, string: String) +fn write_utf8(blob: Blob, range: RangeInclusive, string: String) +fn write_utf8(blob: Blob, start: int, len: int, string: String) +``` + +
+
+ +
+ +
+Write a string to the bytes within an exclusive `range` in the BLOB in UTF-8 encoding. + +* If number of bytes in `range` < length of `string`, extra bytes in `string` are not written. +* If number of bytes in `range` > length of `string`, extra bytes in `range` are not modified. + +```rhai +let b = blob(8); + +b.write_utf8(1..5, "朝には紅顔ありて夕べには白骨となる"); + +print(b); // prints "[00e69c9de3000000]" +``` +
+ +
+
+
+
+

fn zip

+ +```rust,ignore +fn zip(array1: Array, array2: Array, map: FnPtr) -> Array +``` + +
+
+ + + +
+ +
+Iterate through all elements in two arrays, applying a `mapper` function to them, +and return a new array containing the results. +
+ + + +
+
+
diff --git a/docs/src/modules/stdlib.md b/docs/src/modules/stdlib.md index 24d3de5..ee8f866 100644 --- a/docs/src/modules/stdlib.md +++ b/docs/src/modules/stdlib.md @@ -1,291 +1,1039 @@ -# Standard Library +# monitor -## `std::env` +```Namespace: global/std/monitor``` -The `std::env` module provides access to common system-level environment queries. It is supported on Unix-based systems (Linux, macOS). +
+

fn all_resolutions

-### Usage - -```js -import "std::env" as env; - -// Get an environment variable, or fallback to a default -let shell = env::get_env("SHELL") ?? "unknown"; - -// Set an environment variable (current process only) -env::set_env("DEBUG_MODE", "true"); - -// Get the user's home directory -let home = env::get_home_dir() ?? "/home/user"; - -// Get the current working directory -let cwd = env::get_current_dir() ?? "/"; - -// Get the current username -let user = env::get_username() ?? "nobody"; +```rust,ignore +fn all_resolutions() -> Vec<[int;2]> ``` -### Functions +
+
+ + + +
-| Function | Description | -| ----------------- | ------------------------------------------------------- | -| `get_env` | Gets an environment variable's value | -| `set_env` | Sets an environment variable (current process only) | -| `get_home_dir` | Returns the current user's home directory path if found | -| `get_current_dir` | Returns the current working directory | -| `get_username` | Gets the current user's username from `$USER` | +
+Get the resolutions of all connected monitors. +
+ + -// Get resolution of the primary monitor -let res = monitor::primary_resolution(); // e.g. ["1920", "1080"] -let res_str = monitor::primary_resolution_str(); // e.g., "1920x1080" +
+
+
+
+

fn all_resolutions_str

-// Get resolutions of all monitors -let all_res = monitor::all_resolutions(); // e.g., [["1920", "1080"], ["1280", "1024"]] -let all_res_str = monitor::all_resolutions_str(); // e.g., "1920x1080, 1280x1024" - -// Get dimensions of a specific monitor (x, y, width, height) -let dim = monitor::dimensions(0); // e.g. ["0", "0", "1920", "1080"] -let dim_str = monitor::dimensions_str(0); // e.g., "0,0 - 1920x1080" - -// Get DPI of a monitor -let dpi = monitor::dpi(0); // e.g. 96.0 (floating number) -let dpi_str = monitor::dpi_str(0); // e.g., "96.0" +```rust,ignore +fn all_resolutions_str() -> String ``` -### Functions +
+
+ + + +
-| Function | Description | -| -------------------------- | --------------------------------------------------------------------------------------------- | -| `count()` | Returns the number of connected monitors. | -| `primary_resolution()` | Returns the width and height of the primary monitor as an array `[width, height]`. | -| `primary_resolution_str()` | Returns the primary monitor resolution as a string in the format `"WIDTHxHEIGHT"`. | -| `all_resolutions()` | Returns an array of `[width, height]` arrays for all connected monitors. | -| `all_resolutions_str()` | Returns a comma-separated string of all monitor resolutions in `"WIDTHxHEIGHT"` format. | -| `dimensions(index)` | Returns `[x, y, width, height]` for the monitor at the given index. | -| `dimensions_str(index)` | Returns the dimensions of the monitor at the given index as a formatted string `"x,y - WxH"`. | -| `dpi(index)` | Returns the DPI (dots per inch) of the monitor at the given index, accounting for scaling. | -| `dpi_str(index)` | Returns the DPI as a formatted string with one decimal place, e.g., `"96.0"`. | +
+Get the resolutions of all connected monitors as a string. +
+ + -// Convert JSON back to string -let json_str = json::to_string(json_val); +
+
+
+
+

fn count

-// Get a value from a JSON object -let name = json::get(json_val, "name"); // "Alice" - -// Set a value in a JSON object -json::set(json_val, "age", 31); +```rust,ignore +fn count() -> int ``` -### Functions +
+
+ + + +
-| Function | Description | -| -------------- | ----------------------------------------------------------------------------------------------------------------- | -| `parse_json()` | Parses a JSON string into a Rhai `Dynamic` representing a `serde_json::Value`. Returns an error if parsing fails. | -| `to_string()` | Serializes a `Dynamic` JSON value back into a JSON string. | -| `get()` | Retrieves a value by key from a JSON object. Returns `()` if the key does not exist. | -| `set()` | Sets a key-value pair in a JSON object. Returns an error if the value is not a JSON object. | +
+Get the number of connected monitors. +
+ + -// Basic math -let x = math::abs(-42.0); // 42 -let y = math::sqrt(9.0); // 3 -let z = math::pow(2.0, 10.0); // 1024 +
+
+
+
+

fn dimensions

-// Trigonometry -let s = math::sin(math::PI / 2); // ~1 -let c = math::cos(0.0); // 1 -let t = math::tan(math::PI / 4); // ~1 - -// Exponentials & logs -let e = math::exp(1.0); // ~2.718 -let l = math::ln(math::E); // 1 -let l10 = math::log10(100.0); // 2 -let l2 = math::log(2.0, 8.0); // 3 - -// Inverse trig -let a = math::asin(1.0); // PI/2 -let b = math::acos(0.0); // PI/2 -let c = math::atan(1.0); // PI/4 -let d = math::atan2(1.0, 1.0); // PI/4 - -// Hyperbolic -let sh = math::sinh(1.0); -let ch = math::cosh(1.0); -let th = math::tanh(1.0); - -// Utilities -let f = math::floor(3.7); // 3 -let r = math::round(3.5); // 4 -let m = math::min(10.0, 20.0); // 10 -let M = math::max(10.0, 20.0); // 20 -let cl = math::clamp(15.0, 0.0, 10.0); // 10 - -// Other Utilities -let tof = math::to_float(42); // 42 -> 42.0 -let toi = math::to_int(3.14); // truncates toward zero -> 3 -// NOTE: to_int does NOT round! -// If you want nearest integer, use: to_int(math::round(3.14)) +```rust,ignore +fn dimensions(index: int) -> [int;4] ``` -### Constants +
+
+ + + + +
-| Constant | Value | Description | -| -------- | -------- | ---------------- | -| `PI` | 3.14159… | Circle ratio π | -| `E` | 2.71828… | Euler’s number | -| `TAU` | 6.28318… | Full circle (2π) | +
+Get the dimensions (x, y, width, height) of a specific monitor. +
+ + + -// run a command and read output from stdout -let output = command::run_and_read("pwd"); // example output: /home/foo/.config/ewwii/ +
+
+
+
+

fn dimensions_str

+ +```rust,ignore +fn dimensions_str(index: int) -> String ``` -### Functions +
+
+ + + + +
-| Function | Description | -| ----------------- | -------------------------------------------------- | -| `run(x)` | Run the shell command in `x` | -| `run_and_read(x)` | Run the shell command in `x` and return the stdout | +
+Get the dimensions of a specific monitor as a string. +
+ + + + +
+
+
+
+

fn dpi

+ +```rust,ignore +fn dpi(index: int) -> float +``` + +
+
+ + + + +
+ +
+Get the DPI (dots per inch) of a specific monitor. +
+ + + + +
+
+
+
+

fn dpi_str

+ +```rust,ignore +fn dpi_str(index: int) -> String +``` + +
+
+ + + + +
+ +
+Get the DPI of a specific monitor as a string. +
+ + + + +
+
+
+
+

fn primary_resolution

+ +```rust,ignore +fn primary_resolution() -> [int;2] +``` + +
+
+ + + +
+ +
+Get the resolution of the primary monitor. +
+ + + +
+
+
+
+

fn primary_resolution_str

+ +```rust,ignore +fn primary_resolution_str() -> String +``` + +
+
+ + + +
+ +
+Get the resolution of the primary monitor as a string. +
+ + + +
+
+
+ +# command + +```Namespace: global/std/command``` + +
+

fn run

+ +```rust,ignore +fn run(cmd: String) +``` + +
+
+ + + + +
+ +
+Executes a shell command without capturing the output. +
+ + + + +
+
+
+
+

fn run_and_read

+ +```rust,ignore +fn run_and_read(cmd: String) -> String +``` + +
+
+ + + + +
+ +
+Executes a shell command and captures its output. +
+ + + + +
+
+
+ +# text + +```Namespace: global/std/text``` + +
+

fn to_camel_case

+ +```rust,ignore +fn to_camel_case(text: String) -> String +``` + +
+
+ + + + +
+ +
+Converts a string to camel case. +
+ + + + +
+
+
+
+

fn to_lower

+ +```rust,ignore +fn to_lower(s: String) -> String +``` + +
+
+ + + + +
+ +
+Converts a string to lowercase. +
+ + + + +
+
+
+
+

fn to_slug

+ +```rust,ignore +fn to_slug(text: String) -> String +``` + +
+
+ + + + +
+ +
+Converts a string to a slug (lowercase words joined by hyphens). +
+ + + + +
+
+
+
+

fn to_upper

+ +```rust,ignore +fn to_upper(s: String) -> String +``` + +
+
+ + + + +
+ +
+Converts a string to uppercase. +
+ + + + +
+
+
+
+

fn truncate_chars

+ +```rust,ignore +fn truncate_chars(text: String, max_chars: int) -> String +``` + +
+
+ + + + +
+ +
+Truncates a string to the specified number of characters. +
+ + + + +
+
+
+ +# env + +```Namespace: global/std/env``` + +
+

fn get_current_dir

+ +```rust,ignore +fn get_current_dir() -> String +``` + +
+
+ + + +
+ +
+Get the current working directory. +
+ + + +
+
+
+
+

fn get_env

+ +```rust,ignore +fn get_env(var: String) -> String +``` + +
+
+ + + + +
+ +
+Get the value of an environment variable. +
+ + + + +
+
+
+
+

fn get_home_dir

+ +```rust,ignore +fn get_home_dir() -> String +``` + +
+
+ + + +
+ +
+Get the path to the home directory. +
+ + + +
+
+
+
+

fn get_username

+ +```rust,ignore +fn get_username() -> String +``` + +
+
+ + + +
+ +
+Get the current username. +
+ + + +
+
+
+
+

fn set_env

+ +```rust,ignore +fn set_env(var: String, value: String) +``` + +
+
+ + + + +
+ +
+Set the value of an environment variable. +
+ + + + +
+
+
diff --git a/docs/theme/rhai-autodocs/default.css b/docs/theme/rhai-autodocs/default.css new file mode 100644 index 0000000..d5117d2 --- /dev/null +++ b/docs/theme/rhai-autodocs/default.css @@ -0,0 +1,54 @@ +pre { + display: block; + font-family: monospace; + white-space: pre; + margin: 0px; +} + +.func-name { + /* override mdbook default margin for h2/h3 */ + margin-top: 0em; +} + +/* Annotations for a diagram or a snippet */ +.ann { + text-align: center; + font-size: 0.8em; + font-style: italic; +} + +/* custom css for the rust SectionFormat::Tabs option */ +/* NOTE: variables used here are from mdbook's css */ + +.tab { + overflow: hidden; + border-left: 1px solid var(--theme-hover); + border-right: 1px solid var(--theme-hover); +} + +.tab button { + color: var(--icons); + background-color: var(--theme-hover); + float: left; + border: none; + outline: none; + cursor: pointer; + padding: 14px 16px; + transition: 0.3s; +} + +.tab button:hover { + color: var(--icons-hover); + background-color: var(--theme-hover); +} + +.tab button.active { + background-color: var(--theme-bg); +} + +.tabcontent { + display: none; + padding: 6px 12px; + border: 1px solid var(--theme-hover); + border-top: none; +} diff --git a/docs/theme/rhai-autodocs/tabs.js b/docs/theme/rhai-autodocs/tabs.js new file mode 100644 index 0000000..0f6cc13 --- /dev/null +++ b/docs/theme/rhai-autodocs/tabs.js @@ -0,0 +1,23 @@ +function openTab(evt, group, tab) { + const tabcontent = document.getElementsByClassName("tabcontent"); + + for (let i = 0; i < tabcontent.length; i++) { + if (tabcontent[i].getAttribute("group") === group) { + tabcontent[i].style.display = "none"; + } + } + + const tablinks = document.getElementsByClassName("tablinks"); + + for (let i = 0; i < tablinks.length; i++) { + if (tabcontent[i].getAttribute("group") === group) { + tablinks[i].className = tablinks[i].className.replace( + " active", + "" + ); + } + } + + document.getElementById(`${group}-${tab}`).style.display = "block"; + evt.currentTarget.className += " active"; +} diff --git a/heaptrack.ewwii.320299.zst b/heaptrack.ewwii.320299.zst deleted file mode 100644 index cb5b104ac933d72edbdda93c0d54bc44cddd138a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17755 zcmV*mKuNzSwJ-eySam7_%0F*@E8tFKs2#O3_dzW}Q;9ediiLH-vE}A@W3dEyqjDwL z-4z849@U63LXp8CLI|`6!3Rg38Ab!dC{|~!24vM8G6UpPQOl1r{UBHFp4#uM3nxG1 zerHJ$ngO!vXMN7f-I-xLJ7=v1M4hvopff_HYPs?B%PElo%yDd(pi7z zIV*eSXGzgH-EB^v8OH9jRs*uf3=q@T*Js&hh`RTLO5(>uw!In8vro;J7*_ZBjqe}hMSlCHnA~hMNLVs)-oV$%$+4&V~jC|(->n6 z-)eF{ zV+P1EeAdioeCB+1_RRaZ*$j~1v)(g5LyGR`+SGg2d}qGAySv9Yx?Mf2s)kinnN?NQ zFe5!vJ@Ydzta-|+XU%4Sto&5TXJ^m+@(kUr9z=ZRdS{QBXT9?B%+Cxu8XyY~&-|?K z4Bct!vu1!ap844;H;iX}(xT#-8|h4o#CC` zo#mx7AiQU1@6P(p&|T{DIdfg*?3KPMXMNIBxpHRE(Evf^PPuYi&QLkj%d=*HXt^v` z&c0kJr`CG)y4JE@hR(8tr@D;$QM$}`*(=vv)=A9(!F6kyK{W$p{l9wu^hHflGa%^E zoAWV?W-Wrnlr#fGAuneJ zWT8gL5*ftE@{$>lU!*7zqC=gI7?JrOd*#ZH^-0Idonr?39CP^W(Sx#?-H-XXW3Ns* z%UB;{tei1skdtYH%rVBCM0P)D1_+x~W3M#PSRXW2&afGDv%+}pC2&>o0dJBAYCb^5XR zgjS1%l^Q>-`+BAJXAhM0(($C$=a}4OTCJQlf{vQuguA%!(pqLf*eL6&Egr%&td^I~ z9>}U4YXsF=adXd~GXvzb=t@g$qiN_~uJI2?0^u7f?a&@bT06G8X+0j{ut*>*C=?E_ z5W(YsU|jHb-OmgV&or}6?wJA7X?Uy=lqc;~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^KhKrERe**do;{1AR~163Qe zu#ozYsh;GKxfhF?4m&d*D$q&ZW)`WrHU&u6b1iw{_BxcLyR z7UCWk4)6Dtr`L3NJgS1Xn!HiuB~5Uu2aO;Sw&`oYMZgF$;kbBX@&T7y?B~2r!iDj^ z{(IY3K{`q_VXWGKq5^Q8^FFR9P~BmB)e(3MNB{}|ivHncvQ`osogYCT&tMcav2@rd zN{hwNSTvo04`qPwLBbQm-eKRO`-g(8wkN@GXjSRtPdbw3kT#Ebe@tvA z`#zjLiOR$4)X>wAD&mV`?WzC>WJ0)CAcDz|$JyJJTq9%Tqi7->$@hc=IHBJ?s{~X! z_gOZe%)&#Eh79|C$Jg)Y-qWIoj}afrs?sT9r-zs`w+)VId|dwsl8!%I>X(z<6fc+?2{#p@A*8_c1fUV zW`4i&*8q>|U1Xde)w6$xM@VJ@`t|p6rF;9JP2^S6pqC)xK2T$39*8r~?c&ohkg?SR z4q5o~i(EjEd8F?p3rdS-@rO0M?x-9Ll0{1NZ^llMCryr}8&22j4?2R?KfzETbTdr$6m_W~ zdjfr%kG#@yR#aK2QL`5Xn8E^JHcOocIq^>rHd3J8vQHE_m9e{1O_wxi_gcCCZ_t_O zB~ULayX+UBqand$ccA7|OZOrj zD?ztPoFGs{bu`xE(~4vnz2fZz6uDZk<;3~EH1TP3AOk|gf<_e-t_23$b=!(pc>zYo zoq`o0Eu6sI_O~fm1p0r^@6;l=r>TY5ealxbxJc2AnJRpt+&W%WaKZMZ1*^avnO_20 m(Ck>&Uz1Xl#}sy`R(?ROOeL)Zs3V5T2Cx%xSN#FdkJe`VMtn;E diff --git a/tools/README.md b/tools/README.md new file mode 100644 index 0000000..28d5fd1 --- /dev/null +++ b/tools/README.md @@ -0,0 +1,13 @@ +# Ewwii tools + +## 1. generate-rhai-docs + +Generate rhai docs is a tool that will generate the documentation of rhai's builtin stdlib. + +### How to run + +Run the following command in the root of the repository to run `generate-rhai-docs`: + +```bash +$ cargo run --release -p generate-rhai-docs +``` diff --git a/tools/generate-rhai-docs/.gitignore b/tools/generate-rhai-docs/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/tools/generate-rhai-docs/.gitignore @@ -0,0 +1 @@ +/target diff --git a/tools/generate-rhai-docs/Cargo.lock b/tools/generate-rhai-docs/Cargo.lock new file mode 100644 index 0000000..87f4d4d --- /dev/null +++ b/tools/generate-rhai-docs/Cargo.lock @@ -0,0 +1,612 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "const-random", + "getrandom 0.3.3", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "bitflags" +version = "2.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34efbcccd345379ca2868b2b2c9d3782e9cc58ba87bc7d79d5b53d9c9ae6f25d" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "cfg-if" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" + +[[package]] +name = "const-random" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom 0.2.16", + "once_cell", + "tiny-keccak", +] + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "darling" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "derive_builder" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "derive_builder_macro" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" +dependencies = [ + "derive_builder_core", + "syn", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "generate-rhai-docs" +version = "0.1.0" +dependencies = [ + "rhai", + "rhai-autodocs", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.1+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasi 0.14.3+wasi-0.2.4", +] + +[[package]] +name = "handlebars" +version = "6.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759e2d5aea3287cb1190c8ec394f42866cb5bf74fcbf213f354e3c856ea26098" +dependencies = [ + "derive_builder", + "log", + "num-order", + "pest", + "pest_derive", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "libc" +version = "0.2.175" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" + +[[package]] +name = "log" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" + +[[package]] +name = "memchr" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" + +[[package]] +name = "num-modular" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17bb261bf36fa7d83f4c294f834e91256769097b3cb505d44831e0a179ac647f" + +[[package]] +name = "num-order" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "537b596b97c40fcf8056d153049eb22f481c17ebce72a513ec9286e4986d1bb6" +dependencies = [ + "num-modular", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "pest" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323" +dependencies = [ + "memchr", + "thiserror", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb056d9e8ea77922845ec74a1c4e8fb17e7c218cc4fc11a15c5d25e189aa40bc" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e404e638f781eb3202dc82db6760c8ae8a1eeef7fb3fa8264b2ef280504966" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pest_meta" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd1101f170f5903fde0914f899bb503d9ff5271d7ba76bbb70bea63690cc0d5" +dependencies = [ + "pest", + "sha2", +] + +[[package]] +name = "portable-atomic" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" + +[[package]] +name = "proc-macro2" +version = "1.0.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "rhai" +version = "1.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2780e813b755850e50b178931aaf94ed24f6817f46aaaf5d21c13c12d939a249" +dependencies = [ + "ahash", + "bitflags", + "instant", + "num-traits", + "once_cell", + "rhai_codegen", + "serde", + "serde_json", + "smallvec", + "smartstring", + "thin-vec", +] + +[[package]] +name = "rhai-autodocs" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ebabdcbc322e497a1a6d20a18b2c667db2eaf8246d0e3288def5648af86c46a" +dependencies = [ + "handlebars", + "rhai", + "serde", + "serde_json", +] + +[[package]] +name = "rhai_codegen" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5a11a05ee1ce44058fa3d5961d05194fdbe3ad6b40f904af764d81b86450e6b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.143" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" +dependencies = [ + "serde", +] + +[[package]] +name = "smartstring" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" +dependencies = [ + "autocfg", + "serde", + "static_assertions", + "version_check", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thin-vec" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "144f754d318415ac792f9d69fc87abbbfc043ce2ef041c60f16ad828f638717d" +dependencies = [ + "serde", +] + +[[package]] +name = "thiserror" +version = "2.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "typenum" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" + +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasi" +version = "0.14.3+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a51ae83037bdd272a9e28ce236db8c07016dd0d50c27038b3f407533c030c95" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wit-bindgen" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052283831dbae3d879dc7f51f3d92703a316ca49f91540417d38591826127814" + +[[package]] +name = "zerocopy" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/tools/generate-rhai-docs/Cargo.toml b/tools/generate-rhai-docs/Cargo.toml new file mode 100644 index 0000000..6f7b577 --- /dev/null +++ b/tools/generate-rhai-docs/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "generate-rhai-docs" +version = "0.1.0" +edition = "2024" + +[dependencies] +iirhai.workspace = true +rhai = "1.22.2" +rhai-autodocs = "0.9.0" diff --git a/tools/generate-rhai-docs/rhai_docs/global.md b/tools/generate-rhai-docs/rhai_docs/global.md new file mode 100644 index 0000000..924379a --- /dev/null +++ b/tools/generate-rhai-docs/rhai_docs/global.md @@ -0,0 +1,6655 @@ +# global + +```Namespace: global``` + +
+

op !=

+ +```rust,ignore +op int != f32 -> bool +op i128 != i128 -> bool +op i16 != i16 -> bool +op i8 != i8 -> bool +op Array != Array -> bool +op u16 != u16 -> bool +op Instant != Instant -> bool +op Map != Map -> bool +op f32 != int -> bool +op u128 != u128 -> bool +op f32 != f32 -> bool +op i32 != i32 -> bool +op u64 != u64 -> bool +op u32 != u32 -> bool +op u8 != u8 -> bool +``` + +
+
+ + +
+ +
+Return `true` if two arrays are not-equal (i.e. any element not equal or not in the same order). + +The operator `==` is used to compare elements and must be defined, +otherwise `false` is assumed. +
+ + +
+
+
+
+

fn +

+ +```rust,ignore +fn +(x: i8) -> i8 +fn +(x: int) -> int +fn +(x: float) -> float +fn +(x: i128) -> i128 +fn +(x: i32) -> i32 +fn +(x: f32) -> f32 +fn +(x: i16) -> i16 +fn +(x: u32, y: u32) -> u32 +fn +(x: u8, y: u8) -> u8 +fn +(x: u64, y: u64) -> u64 +fn +(string1: String, string2: String) -> String +fn +(timestamp: Instant, seconds: int) -> Instant +fn +(string: String, character: char) -> String +fn +(x: i32, y: i32) -> i32 +fn +(timestamp: Instant, seconds: float) -> Instant +fn +(x: f32, y: f32) -> f32 +fn +(map1: Map, map2: Map) -> Map +fn +(x: u128, y: u128) -> u128 +fn +(x: f32, y: int) -> f32 +fn +(character: char, string: String) -> String +fn +(utf8: Blob, string: String) -> String +fn +(item: ?, string: String) -> String +fn +(array1: Array, array2: Array) -> Array +fn +(x: u16, y: u16) -> u16 +fn +(string: String, mut item: ?) -> String +fn +(string: String, utf8: Blob) -> String +fn +(x: i8, y: i8) -> i8 +fn +(item: ?, string: String) -> String +fn +(x: int, y: f32) -> f32 +fn +(x: i128, y: i128) -> i128 +fn +(x: i16, y: i16) -> i16 +fn +(string: String, item: ?) -> String +``` + +
+
+ +
+ +
+Add the specified number of `seconds` to the timestamp and return it as a new timestamp. +
+ +
+
+
+
+

fn +=

+ +```rust,ignore +fn +=(string1: String, string2: String) +fn +=(map: Map, map2: Map) +fn +=(timestamp: Instant, seconds: float) +fn +=(string: String, character: char) +fn +=(timestamp: Instant, seconds: int) +fn +=(string: String, mut item: ?) +fn +=(string: String, item: ?) +fn +=(string: String, utf8: Blob) +``` + +
+
+ + +
+ +
+Add all property values of another object map into the object map. +Existing property values of the same names are replaced. +
+ + +
+
+
+
+

fn -

+ +```rust,ignore +fn -(x: float) -> float +fn -(x: int) -> int +fn -(x: i8) -> i8 +fn -(x: f32) -> f32 +fn -(x: i16) -> i16 +fn -(x: i128) -> i128 +fn -(x: i32) -> i32 +fn -(x: i8, y: i8) -> i8 +fn -(x: int, y: f32) -> f32 +fn -(x: i128, y: i128) -> i128 +fn -(x: i16, y: i16) -> i16 +fn -(timestamp1: Instant, timestamp2: Instant) -> ? +fn -(x: u16, y: u16) -> u16 +fn -(timestamp: Instant, seconds: int) -> Instant +fn -(x: i32, y: i32) -> i32 +fn -(x: f32, y: f32) -> f32 +fn -(timestamp: Instant, seconds: float) -> Instant +fn -(x: u128, y: u128) -> u128 +fn -(x: f32, y: int) -> f32 +fn -(x: u32, y: u32) -> u32 +fn -(x: u8, y: u8) -> u8 +fn -(x: u64, y: u64) -> u64 +``` + +
+
+ +
+ +
+Return the number of seconds between two timestamps. +
+ +
+
+
+
+

fn -=

+ +```rust,ignore +fn -=(timestamp: Instant, seconds: float) +fn -=(timestamp: Instant, seconds: int) +``` + +
+
+ +
+ +
+Subtract the specified number of `seconds` from the timestamp. +
+ +
+
+
+
+

op <

+ +```rust,ignore +op int < f32 -> bool +op i128 < i128 -> bool +op i16 < i16 -> bool +op i8 < i8 -> bool +op u16 < u16 -> bool +op Instant < Instant -> bool +op u128 < u128 -> bool +op f32 < int -> bool +op i32 < i32 -> bool +op f32 < f32 -> bool +op u64 < u64 -> bool +op u32 < u32 -> bool +op u8 < u8 -> bool +``` + +
+
+ +
+ +
+Return `true` if the first timestamp is earlier than the second. +
+ +
+
+
+
+

op <=

+ +```rust,ignore +op Instant <= Instant -> bool +op u16 <= u16 -> bool +op i8 <= i8 -> bool +op int <= f32 -> bool +op i16 <= i16 -> bool +op i128 <= i128 -> bool +op u32 <= u32 -> bool +op u8 <= u8 -> bool +op u64 <= u64 -> bool +op f32 <= f32 -> bool +op i32 <= i32 -> bool +op f32 <= int -> bool +op u128 <= u128 -> bool +``` + +
+
+ +
+ +
+Return `true` if the first timestamp is earlier than or equals to the second. +
+ +
+
+
+
+

op ==

+ +```rust,ignore +op u64 == u64 -> bool +op u8 == u8 -> bool +op u32 == u32 -> bool +op f32 == int -> bool +op u128 == u128 -> bool +op Map == Map -> bool +op f32 == f32 -> bool +op i32 == i32 -> bool +op u16 == u16 -> bool +op Array == Array -> bool +op Instant == Instant -> bool +op i16 == i16 -> bool +op i128 == i128 -> bool +op int == f32 -> bool +op i8 == i8 -> bool +``` + +
+
+ + +
+ +
+Return `true` if two object maps are equal (i.e. all property values are equal). + +The operator `==` is used to compare property values and must be defined, +otherwise `false` is assumed. +
+ + +
+
+
+
+

op >

+ +```rust,ignore +op i32 > i32 -> bool +op f32 > f32 -> bool +op u128 > u128 -> bool +op f32 > int -> bool +op u32 > u32 -> bool +op u8 > u8 -> bool +op u64 > u64 -> bool +op i8 > i8 -> bool +op int > f32 -> bool +op i16 > i16 -> bool +op i128 > i128 -> bool +op Instant > Instant -> bool +op u16 > u16 -> bool +``` + +
+
+ +
+ +
+Return `true` if the first timestamp is later than the second. +
+ +
+
+
+
+

op >=

+ +```rust,ignore +op u128 >= u128 -> bool +op f32 >= int -> bool +op i32 >= i32 -> bool +op f32 >= f32 -> bool +op u64 >= u64 -> bool +op u32 >= u32 -> bool +op u8 >= u8 -> bool +op int >= f32 -> bool +op i128 >= i128 -> bool +op i16 >= i16 -> bool +op i8 >= i8 -> bool +op u16 >= u16 -> bool +op Instant >= Instant -> bool +``` + +
+
+ +
+ +
+Return `true` if the first timestamp is later than or equals to the second. +
+ +
+
+
+
+

get/set ?.tag

+ +```rust,ignore +get ?.tag -> int +set ?.tag = int +``` + +
+
+ + +
+ +
+Return the _tag_ of a `Dynamic` value. +
+ + +
+
+
+
+

get/set Array.is_empty

+ +```rust,ignore +get Array.is_empty -> bool +``` + +
+
+ +
+ +
+Return true if the array is empty. +
+ +
+
+
+
+

get/set Array.len

+ +```rust,ignore +get Array.len -> int +``` + +
+
+ +
+ +
+Number of elements in the array. +
+ +
+
+
+
+

get/set Blob.is_empty

+ +```rust,ignore +get Blob.is_empty -> bool +``` + +
+
+ +
+ +
+Return true if the BLOB is empty. +
+ +
+
+
+
+

get/set Blob.len

+ +```rust,ignore +get Blob.len -> int +``` + +
+
+ + +
+ +
+Return the length of the BLOB. +
+ + +
+
+
+
+

fn E

+ +```rust,ignore +fn E() -> float +``` + +
+
+ +
+ +
+Return the natural number _e_. +
+ +
+
+
+
+

get/set FnPtr.is_anonymous

+ +```rust,ignore +get FnPtr.is_anonymous -> bool +``` + +
+
+ + +
+ +
+Return `true` if the function is an anonymous function. +
+ + +
+
+
+
+

get/set FnPtr.name

+ +```rust,ignore +get FnPtr.name -> String +``` + +
+
+ + +
+ +
+Return the name of the function. +
+ + +
+
+
+
+

get/set Instant.elapsed

+ +```rust,ignore +get Instant.elapsed -> ? +``` + +
+
+ + +
+ +
+Return the number of seconds between the current system time and the timestamp. +
+ + +
+
+
+
+

fn PI

+ +```rust,ignore +fn PI() -> float +``` + +
+
+ +
+ +
+Return the number π. +
+ +
+
+
+
+

get/set Range<int>.end

+ +```rust,ignore +get Range.end -> int +``` + +
+
+ +
+ +
+Return the end of the exclusive range. +
+ +
+
+
+
+

get/set Range<int>.is_empty

+ +```rust,ignore +get Range.is_empty -> bool +``` + +
+
+ +
+ +
+Return true if the range contains no items. +
+ +
+
+
+
+

get/set Range<int>.is_exclusive

+ +```rust,ignore +get Range.is_exclusive -> bool +``` + +
+
+ +
+ +
+Return `true` if the range is exclusive. +
+ +
+
+
+
+

get/set Range<int>.is_inclusive

+ +```rust,ignore +get Range.is_inclusive -> bool +``` + +
+
+ +
+ +
+Return `true` if the range is inclusive. +
+ +
+
+
+
+

get/set Range<int>.start

+ +```rust,ignore +get Range.start -> int +``` + +
+
+ +
+ +
+Return the start of the exclusive range. +
+ +
+
+
+
+

get/set RangeInclusive<int>.end

+ +```rust,ignore +get RangeInclusive.end -> int +``` + +
+
+ +
+ +
+Return the end of the inclusive range. +
+ +
+
+
+
+

get/set RangeInclusive<int>.is_empty

+ +```rust,ignore +get RangeInclusive.is_empty -> bool +``` + +
+
+ +
+ +
+Return true if the range contains no items. +
+ +
+
+
+
+

get/set RangeInclusive<int>.is_exclusive

+ +```rust,ignore +get RangeInclusive.is_exclusive -> bool +``` + +
+
+ +
+ +
+Return `true` if the range is exclusive. +
+ +
+
+
+
+

get/set RangeInclusive<int>.is_inclusive

+ +```rust,ignore +get RangeInclusive.is_inclusive -> bool +``` + +
+
+ +
+ +
+Return `true` if the range is inclusive. +
+ +
+
+
+
+

get/set RangeInclusive<int>.start

+ +```rust,ignore +get RangeInclusive.start -> int +``` + +
+
+ +
+ +
+Return the start of the inclusive range. +
+ +
+
+
+
+

get/set String.bytes

+ +```rust,ignore +get String.bytes -> int +``` + +
+
+ + +
+ +
+Return the length of the string, in number of bytes used to store it in UTF-8 encoding. +
+ + +
+
+
+
+

get/set String.chars

+ +```rust,ignore +get String.chars -> CharsStream +``` + +
+
+ + +
+ +
+Return an iterator over all the characters in the string. +
+ + +
+
+
+
+

get/set String.is_empty

+ +```rust,ignore +get String.is_empty -> bool +``` + +
+
+ +
+ +
+Return true if the string is empty. +
+ +
+
+
+
+

get/set String.len

+ +```rust,ignore +get String.len -> int +``` + +
+
+ + +
+ +
+Return the length of the string, in number of characters. +
+ + +
+
+
+
+

fn abs

+ +```rust,ignore +fn abs(x: i8) -> i8 +fn abs(x: int) -> int +fn abs(x: float) -> float +fn abs(x: i32) -> i32 +fn abs(x: i128) -> i128 +fn abs(x: i16) -> i16 +fn abs(x: f32) -> f32 +``` + +
+
+ +
+ +
+Return the absolute value of the number. +
+ +
+
+
+
+

fn acos

+ +```rust,ignore +fn acos(x: float) -> float +``` + +
+
+ +
+ +
+Return the arc-cosine of the floating-point number, in radians. +
+ +
+
+
+
+

fn acosh

+ +```rust,ignore +fn acosh(x: float) -> float +``` + +
+
+ +
+ +
+Return the arc-hyperbolic-cosine of the floating-point number, in radians. +
+ +
+
+
+
+

fn all

+ +```rust,ignore +fn all(array: Array, filter: String) -> bool +fn all(array: Array, filter: FnPtr) -> bool +``` + +
+
+ + + + +
+ +
+Return `true` if all elements in the array return `true` when applied a function named by `filter`. +
+ + + + +
+
+
+
+

fn append

+ +```rust,ignore +fn append(blob1: Blob, blob2: Blob) +fn append(blob: Blob, character: char) +fn append(blob: Blob, value: int) +fn append(string: String, mut item: ?) +fn append(array: Array, new_array: Array) +fn append(blob: Blob, string: String) +fn append(string: String, utf8: Blob) +``` + +
+
+ + +
+ +
+Add another BLOB to the end of the BLOB. +
+ + +
+
+
+
+

fn as_string

+ +```rust,ignore +fn as_string(blob: Blob) -> String +``` + +
+
+ + +
+ +
+Convert the BLOB into a string. + +The byte stream must be valid UTF-8, otherwise an error is raised. +
+ + +
+
+
+
+

fn asin

+ +```rust,ignore +fn asin(x: float) -> float +``` + +
+
+ +
+ +
+Return the arc-sine of the floating-point number, in radians. +
+ +
+
+
+
+

fn asinh

+ +```rust,ignore +fn asinh(x: float) -> float +``` + +
+
+ +
+ +
+Return the arc-hyperbolic-sine of the floating-point number, in radians. +
+ +
+
+
+
+

fn atan

+ +```rust,ignore +fn atan(x: float) -> float +fn atan(x: float, y: float) -> float +``` + +
+
+ +
+ +
+Return the arc-tangent of the floating-point number, in radians. +
+ +
+
+
+
+

fn atanh

+ +```rust,ignore +fn atanh(x: float) -> float +``` + +
+
+ +
+ +
+Return the arc-hyperbolic-tangent of the floating-point number, in radians. +
+ +
+
+
+
+

fn bits

+ +```rust,ignore +fn bits(value: int) -> BitRange +fn bits(value: int, range: RangeInclusive) -> BitRange +fn bits(value: int, range: Range) -> BitRange +fn bits(value: int, from: int) -> BitRange +fn bits(value: int, from: int, len: int) -> BitRange +``` + +
+
+ + +
+ +
+Return an iterator over all the bits in the number. +
+ + +
+
+
+
+

fn blob

+ +```rust,ignore +fn blob() -> Blob +fn blob(len: int) -> Blob +fn blob(len: int, value: int) -> Blob +``` + +
+
+ +
+ +
+Return a new, empty BLOB. +
+ +
+
+
+
+

fn bytes

+ +```rust,ignore +fn bytes(string: String) -> int +``` + +
+
+ + +
+ +
+Return the length of the string, in number of bytes used to store it in UTF-8 encoding. +
+ + +
+
+
+
+

fn ceiling

+ +```rust,ignore +fn ceiling(x: float) -> float +``` + +
+
+ +
+ +
+Return the smallest whole number larger than or equals to the floating-point number. +
+ +
+
+
+
+

fn chars

+ +```rust,ignore +fn chars(string: String) -> CharsStream +fn chars(string: String, range: Range) -> CharsStream +fn chars(string: String, range: RangeInclusive) -> CharsStream +fn chars(string: String, start: int) -> CharsStream +fn chars(string: String, start: int, len: int) -> CharsStream +``` + +
+
+ + +
+ +
+Return an iterator over the characters in the string. +
+ + +
+
+
+
+

fn chop

+ +```rust,ignore +fn chop(blob: Blob, len: int) +fn chop(array: Array, len: int) +``` + +
+
+ + +
+ +
+Cut off the head of the BLOB, leaving a tail of the specified length. + +* If `len` ≤ 0, the BLOB is cleared. +* If `len` ≥ length of BLOB, the BLOB is not modified. +
+ + +
+
+
+
+

fn clear

+ +```rust,ignore +fn clear(string: String) +fn clear(array: Array) +fn clear(map: Map) +fn clear(blob: Blob) +``` + +
+
+ +
+ +
+Clear the string, making it empty. +
+ +
+
+
+
+

fn contains

+ +```rust,ignore +fn contains(array: Array, value: ?) -> bool +fn contains(map: Map, property: String) -> bool +fn contains(blob: Blob, value: int) -> bool +fn contains(string: String, character: char) -> bool +fn contains(range: Range, value: int) -> bool +fn contains(string: String, match_string: String) -> bool +fn contains(range: RangeInclusive, value: int) -> bool +``` + +
+
+ + +
+ +
+Return `true` if the array contains an element that equals `value`. + +The operator `==` is used to compare elements with `value` and must be defined, +otherwise `false` is assumed. + +This function also drives the `in` operator. +
+ + +
+
+
+
+

fn cos

+ +```rust,ignore +fn cos(x: float) -> float +``` + +
+
+ +
+ +
+Return the cosine of the floating-point number in radians. +
+ +
+
+
+
+

fn cosh

+ +```rust,ignore +fn cosh(x: float) -> float +``` + +
+
+ +
+ +
+Return the hyperbolic cosine of the floating-point number in radians. +
+ +
+
+
+
+

fn crop

+ +```rust,ignore +fn crop(string: String, start: int) +fn crop(string: String, range: Range) +fn crop(string: String, range: RangeInclusive) +fn crop(string: String, start: int, len: int) +``` + +
+
+ + +
+ +
+Remove all characters from the string up to the `start` position. + +* If `start` < 0, position counts from the end of the string (`-1` is the last character). +* If `start` < -length of string, the string is not modified. +* If `start` ≥ length of string, the entire string is cleared. +
+ + +
+
+
+
+

fn debug

+ +```rust,ignore +fn debug() -> String +fn debug(item: ?) -> String +fn debug(string: String) -> String +fn debug(array: Array) -> String +fn debug(f: FnPtr) -> String +fn debug(number: f32) -> String +fn debug(map: Map) -> String +fn debug(unit: ?) -> String +fn debug(number: float) -> String +fn debug(character: char) -> String +fn debug(value: bool) -> String +``` + +
+
+ +
+ +
+Return the empty string. +
+ +
+
+
+
+

fn dedup

+ +```rust,ignore +fn dedup(array: Array) +fn dedup(array: Array, comparer: FnPtr) +fn dedup(array: Array, comparer: String) +``` + +
+
+ + +
+ +
+Remove duplicated _consecutive_ elements from the array. + +The operator `==` is used to compare elements and must be defined, +otherwise `false` is assumed. +
+ + +
+
+
+
+

fn drain

+ +```rust,ignore +fn drain(array: Array, range: RangeInclusive) -> Array +fn drain(map: Map, filter: FnPtr) -> Map +fn drain(blob: Blob, range: RangeInclusive) -> Blob +fn drain(array: Array, range: Range) -> Array +fn drain(array: Array, filter: FnPtr) -> Array +fn drain(array: Array, filter: String) -> Array +fn drain(blob: Blob, range: Range) -> Blob +fn drain(blob: Blob, start: int, len: int) -> Blob +fn drain(array: Array, start: int, len: int) -> Array +``` + +
+
+ + +
+ +
+Remove all elements in the array within an inclusive `range` and return them as a new array. +
+ + +
+
+
+
+

fn elapsed

+ +```rust,ignore +fn elapsed(timestamp: Instant) -> ? +``` + +
+
+ + +
+ +
+Return the number of seconds between the current system time and the timestamp. +
+ + +
+
+
+
+

fn end

+ +```rust,ignore +fn end(range: RangeInclusive) -> int +fn end(range: Range) -> int +``` + +
+
+ +
+ +
+Return the end of the inclusive range. +
+ +
+
+
+
+

fn ends_with

+ +```rust,ignore +fn ends_with(string: String, match_string: String) -> bool +``` + +
+
+ + +
+ +
+Return `true` if the string ends with a specified string. +
+ + +
+
+
+
+

fn exit

+ +```rust,ignore +fn exit() -> ? +fn exit(value: ?) -> ? +``` + +
+
+ + +
+ +
+Exit the script evaluation immediately with `()` as exit value. +
+ + +
+
+
+
+

fn exp

+ +```rust,ignore +fn exp(x: float) -> float +``` + +
+
+ +
+ +
+Return the exponential of the floating-point number. +
+ +
+
+
+
+

fn extract

+ +```rust,ignore +fn extract(array: Array, start: int) -> Array +fn extract(blob: Blob, range: Range) -> Blob +fn extract(array: Array, range: Range) -> Array +fn extract(blob: Blob, start: int) -> Blob +fn extract(array: Array, range: RangeInclusive) -> Array +fn extract(blob: Blob, range: RangeInclusive) -> Blob +fn extract(blob: Blob, start: int, len: int) -> Blob +fn extract(array: Array, start: int, len: int) -> Array +``` + +
+
+ + +
+ +
+Copy a portion of the array beginning at the `start` position till the end and return it as +a new array. + +* If `start` < 0, position counts from the end of the array (`-1` is the last element). +* If `start` < -length of array, the entire array is copied and returned. +* If `start` ≥ length of array, an empty array is returned. +
+ + +
+
+
+
+

get/set f32.is_zero

+ +```rust,ignore +get f32.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the floating-point number is zero. +
+ +
+
+
+
+

fn fill_with

+ +```rust,ignore +fn fill_with(map: Map, map2: Map) +``` + +
+
+ + +
+ +
+Add all property values of another object map into the object map. +Only properties that do not originally exist in the object map are added. +
+ + +
+
+
+
+

fn filter

+ +```rust,ignore +fn filter(map: Map, filter: FnPtr) -> Map +fn filter(array: Array, filter: FnPtr) -> Array +fn filter(array: Array, filter_func: String) -> Array +``` + +
+
+ + + +
+ +
+Iterate through all the elements in the object map, applying a `filter` function to each +and return a new collection of all elements that return `true` as a new object map. +
+ + + +
+
+
+
+

fn find

+ +```rust,ignore +fn find(array: Array, filter: FnPtr) -> ? +fn find(array: Array, filter: FnPtr, start: int) -> ? +``` + +
+
+ + + + +
+ +
+Iterate through all the elements in the array, applying a `filter` function to each element +in turn, and return a copy of the first element that returns `true`. If no element returns +`true`, `()` is returned. +
+ + + + +
+
+
+
+

fn find_map

+ +```rust,ignore +fn find_map(array: Array, filter: FnPtr) -> ? +fn find_map(array: Array, filter: FnPtr, start: int) -> ? +``` + +
+
+ + + + +
+ +
+Iterate through all the elements in the array, applying a `mapper` function to each element +in turn, and return the first result that is not `()`. Otherwise, `()` is returned. +
+ + + + +
+
+
+
+

get/set float.ceiling

+ +```rust,ignore +get float.ceiling -> float +``` + +
+
+ +
+ +
+Return the smallest whole number larger than or equals to the floating-point number. +
+ +
+
+
+
+

get/set float.floor

+ +```rust,ignore +get float.floor -> float +``` + +
+
+ +
+ +
+Return the largest whole number less than or equals to the floating-point number. +
+ +
+
+
+
+

get/set float.fraction

+ +```rust,ignore +get float.fraction -> float +``` + +
+
+ +
+ +
+Return the fractional part of the floating-point number. +
+ +
+
+
+
+

get/set float.int

+ +```rust,ignore +get float.int -> float +``` + +
+
+ +
+ +
+Return the integral part of the floating-point number. +
+ +
+
+
+
+

get/set float.is_finite

+ +```rust,ignore +get float.is_finite -> bool +``` + +
+
+ +
+ +
+Return `true` if the floating-point number is finite. +
+ +
+
+
+
+

get/set float.is_infinite

+ +```rust,ignore +get float.is_infinite -> bool +``` + +
+
+ +
+ +
+Return `true` if the floating-point number is infinite. +
+ +
+
+
+
+

get/set float.is_nan

+ +```rust,ignore +get float.is_nan -> bool +``` + +
+
+ +
+ +
+Return `true` if the floating-point number is `NaN` (Not A Number). +
+ +
+
+
+
+

get/set float.is_zero

+ +```rust,ignore +get float.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the floating-point number is zero. +
+ +
+
+
+
+

get/set float.round

+ +```rust,ignore +get float.round -> float +``` + +
+
+ +
+ +
+Return the nearest whole number closest to the floating-point number. +Rounds away from zero. +
+ +
+
+
+
+

fn floor

+ +```rust,ignore +fn floor(x: float) -> float +``` + +
+
+ +
+ +
+Return the largest whole number less than or equals to the floating-point number. +
+ +
+
+
+
+

fn for_each

+ +```rust,ignore +fn for_each(array: Array, map: FnPtr) +``` + +
+
+ + + +
+ +
+Iterate through all the elements in the array, applying a `process` function to each element in turn. +Each element is bound to `this` before calling the function. +
+ + + +
+
+
+
+

fn fraction

+ +```rust,ignore +fn fraction(x: float) -> float +``` + +
+
+ +
+ +
+Return the fractional part of the floating-point number. +
+ +
+
+
+
+

fn get

+ +```rust,ignore +fn get(array: Array, index: int) -> ? +fn get(string: String, index: int) -> ? +fn get(blob: Blob, index: int) -> int +fn get(map: Map, property: String) -> ? +``` + +
+
+ + +
+ +
+Get a copy of the element at the `index` position in the array. + +* If `index` < 0, position counts from the end of the array (`-1` is the last element). +* If `index` < -length of array, `()` is returned. +* If `index` ≥ length of array, `()` is returned. +
+ + +
+
+
+
+

fn get_bit

+ +```rust,ignore +fn get_bit(value: int, bit: int) -> bool +``` + +
+
+ + +
+ +
+Return `true` if the specified `bit` in the number is set. + +If `bit` < 0, position counts from the MSB (Most Significant Bit). +
+ + +
+
+
+
+

fn get_bits

+ +```rust,ignore +fn get_bits(value: int, range: RangeInclusive) -> int +fn get_bits(value: int, range: Range) -> int +fn get_bits(value: int, start: int, bits: int) -> int +``` + +
+
+ + +
+ +
+Return an inclusive range of bits in the number as a new number. +
+ + +
+
+
+
+

fn get_fn_metadata_list

+ +```rust,ignore +fn get_fn_metadata_list() -> Array +fn get_fn_metadata_list(name: String) -> Array +fn get_fn_metadata_list(name: String, params: int) -> Array +``` + +
+
+ +
+ +
+Return an array of object maps containing metadata of all script-defined functions. +
+ +
+
+
+
+

fn hypot

+ +```rust,ignore +fn hypot(x: float, y: float) -> float +``` + +
+
+ +
+ +
+Return the hypotenuse of a triangle with sides `x` and `y`. +
+ +
+
+
+
+

get/set i128.is_even

+ +```rust,ignore +get i128.is_even -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

get/set i128.is_odd

+ +```rust,ignore +get i128.is_odd -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

get/set i128.is_zero

+ +```rust,ignore +get i128.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

get/set i16.is_even

+ +```rust,ignore +get i16.is_even -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

get/set i16.is_odd

+ +```rust,ignore +get i16.is_odd -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

get/set i16.is_zero

+ +```rust,ignore +get i16.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

get/set i32.is_even

+ +```rust,ignore +get i32.is_even -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

get/set i32.is_odd

+ +```rust,ignore +get i32.is_odd -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

get/set i32.is_zero

+ +```rust,ignore +get i32.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

get/set i8.is_even

+ +```rust,ignore +get i8.is_even -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

get/set i8.is_odd

+ +```rust,ignore +get i8.is_odd -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

get/set i8.is_zero

+ +```rust,ignore +get i8.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

fn index_of

+ +```rust,ignore +fn index_of(string: String, find_string: String) -> int +fn index_of(array: Array, filter: String) -> int +fn index_of(string: String, character: char) -> int +fn index_of(array: Array, filter: FnPtr) -> int +fn index_of(array: Array, value: ?) -> int +fn index_of(string: String, character: char, start: int) -> int +fn index_of(array: Array, value: ?, start: int) -> int +fn index_of(array: Array, filter: FnPtr, start: int) -> int +fn index_of(string: String, find_string: String, start: int) -> int +fn index_of(array: Array, filter: String, start: int) -> int +``` + +
+
+ + +
+ +
+Find the specified `character` in the string and return the first index where it is found. +If the `character` is not found, `-1` is returned. +
+ + +
+
+
+
+

fn insert

+ +```rust,ignore +fn insert(blob: Blob, index: int, value: int) +fn insert(array: Array, index: int, item: ?) +``` + +
+
+ + +
+ +
+Add a byte `value` to the BLOB at a particular `index` position. + +* If `index` < 0, position counts from the end of the BLOB (`-1` is the last byte). +* If `index` < -length of BLOB, the byte value is added to the beginning of the BLOB. +* If `index` ≥ length of BLOB, the byte value is appended to the end of the BLOB. + +Only the lower 8 bits of the `value` are used; all other bits are ignored. +
+ + +
+
+
+
+

fn int

+ +```rust,ignore +fn int(x: float) -> float +``` + +
+
+ +
+ +
+Return the integral part of the floating-point number. +
+ +
+
+
+
+

get/set int.bits

+ +```rust,ignore +get int.bits -> BitRange +``` + +
+
+ + +
+ +
+Return an iterator over all the bits in the number. +
+ + +
+
+
+
+

get/set int.is_even

+ +```rust,ignore +get int.is_even -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

get/set int.is_odd

+ +```rust,ignore +get int.is_odd -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

get/set int.is_zero

+ +```rust,ignore +get int.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

fn is_anonymous

+ +```rust,ignore +fn is_anonymous(fn_ptr: FnPtr) -> bool +``` + +
+
+ + +
+ +
+Return `true` if the function is an anonymous function. +
+ + +
+
+
+
+

fn is_empty

+ +```rust,ignore +fn is_empty(blob: Blob) -> bool +fn is_empty(range: Range) -> bool +fn is_empty(array: Array) -> bool +fn is_empty(map: Map) -> bool +fn is_empty(range: RangeInclusive) -> bool +fn is_empty(string: String) -> bool +``` + +
+
+ +
+ +
+Return true if the BLOB is empty. +
+ +
+
+
+
+

fn is_even

+ +```rust,ignore +fn is_even(x: i16) -> bool +fn is_even(x: i32) -> bool +fn is_even(x: u8) -> bool +fn is_even(x: i128) -> bool +fn is_even(x: u32) -> bool +fn is_even(x: u128) -> bool +fn is_even(x: i8) -> bool +fn is_even(x: u64) -> bool +fn is_even(x: u16) -> bool +fn is_even(x: int) -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

fn is_exclusive

+ +```rust,ignore +fn is_exclusive(range: Range) -> bool +fn is_exclusive(range: RangeInclusive) -> bool +``` + +
+
+ +
+ +
+Return `true` if the range is exclusive. +
+ +
+
+
+
+

fn is_finite

+ +```rust,ignore +fn is_finite(x: float) -> bool +``` + +
+
+ +
+ +
+Return `true` if the floating-point number is finite. +
+ +
+
+
+
+

fn is_inclusive

+ +```rust,ignore +fn is_inclusive(range: Range) -> bool +fn is_inclusive(range: RangeInclusive) -> bool +``` + +
+
+ +
+ +
+Return `true` if the range is inclusive. +
+ +
+
+
+
+

fn is_infinite

+ +```rust,ignore +fn is_infinite(x: float) -> bool +``` + +
+
+ +
+ +
+Return `true` if the floating-point number is infinite. +
+ +
+
+
+
+

fn is_nan

+ +```rust,ignore +fn is_nan(x: float) -> bool +``` + +
+
+ +
+ +
+Return `true` if the floating-point number is `NaN` (Not A Number). +
+ +
+
+
+
+

fn is_odd

+ +```rust,ignore +fn is_odd(x: int) -> bool +fn is_odd(x: u16) -> bool +fn is_odd(x: u64) -> bool +fn is_odd(x: i8) -> bool +fn is_odd(x: u128) -> bool +fn is_odd(x: u32) -> bool +fn is_odd(x: i128) -> bool +fn is_odd(x: i32) -> bool +fn is_odd(x: u8) -> bool +fn is_odd(x: i16) -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

fn is_zero

+ +```rust,ignore +fn is_zero(x: u8) -> bool +fn is_zero(x: i32) -> bool +fn is_zero(x: i128) -> bool +fn is_zero(x: i16) -> bool +fn is_zero(x: f32) -> bool +fn is_zero(x: u128) -> bool +fn is_zero(x: float) -> bool +fn is_zero(x: u32) -> bool +fn is_zero(x: i8) -> bool +fn is_zero(x: int) -> bool +fn is_zero(x: u64) -> bool +fn is_zero(x: u16) -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

fn keys

+ +```rust,ignore +fn keys(map: Map) -> Array +``` + +
+
+ + +
+ +
+Return an array with all the property names in the object map. +
+ + +
+
+
+
+

fn len

+ +```rust,ignore +fn len(blob: Blob) -> int +fn len(array: Array) -> int +fn len(map: Map) -> int +fn len(string: String) -> int +``` + +
+
+ + +
+ +
+Return the length of the BLOB. +
+ + +
+
+
+
+

fn ln

+ +```rust,ignore +fn ln(x: float) -> float +``` + +
+
+ +
+ +
+Return the natural log of the floating-point number. +
+ +
+
+
+
+

fn log

+ +```rust,ignore +fn log(x: float) -> float +fn log(x: float, base: float) -> float +``` + +
+
+ +
+ +
+Return the log of the floating-point number with base 10. +
+ +
+
+
+
+

fn make_lower

+ +```rust,ignore +fn make_lower(character: char) +fn make_lower(string: String) +``` + +
+
+ + +
+ +
+Convert the character to lower-case. +
+ + +
+
+
+
+

fn make_upper

+ +```rust,ignore +fn make_upper(string: String) +fn make_upper(character: char) +``` + +
+
+ + +
+ +
+Convert the string to all upper-case. +
+ + +
+
+
+
+

fn map

+ +```rust,ignore +fn map(array: Array, map: FnPtr) -> Array +fn map(array: Array, mapper: String) -> Array +``` + +
+
+ + + + +
+ +
+Iterate through all the elements in the array, applying a `mapper` function to each element +in turn, and return the results as a new array. +
+ + + + +
+
+
+
+

fn max

+ +```rust,ignore +fn max(x: int, y: float) -> float +fn max(x: u8, y: u8) -> u8 +fn max(x: u32, y: u32) -> u32 +fn max(x: u64, y: u64) -> u64 +fn max(x: i32, y: i32) -> i32 +fn max(x: f32, y: f32) -> f32 +fn max(x: float, y: int) -> float +fn max(string1: String, string2: String) -> String +fn max(x: u128, y: u128) -> u128 +fn max(char1: char, char2: char) -> char +fn max(x: f32, y: int) -> f32 +fn max(x: int, y: int) -> int +fn max(x: f32, y: float) -> float +fn max(x: u16, y: u16) -> u16 +fn max(x: float, y: f32) -> float +fn max(x: i8, y: i8) -> i8 +fn max(x: i16, y: i16) -> i16 +fn max(x: i128, y: i128) -> i128 +fn max(x: float, y: float) -> float +fn max(x: int, y: f32) -> f32 +``` + +
+
+ + +
+ +
+Return the string that is lexically greater than the other string. +
+ + +
+
+
+
+

fn min

+ +```rust,ignore +fn min(x: u64, y: u64) -> u64 +fn min(string1: String, string2: String) -> String +fn min(x: u8, y: u8) -> u8 +fn min(x: int, y: float) -> float +fn min(x: u32, y: u32) -> u32 +fn min(x: f32, y: int) -> f32 +fn min(x: u128, y: u128) -> u128 +fn min(char1: char, char2: char) -> char +fn min(x: int, y: int) -> int +fn min(x: f32, y: f32) -> f32 +fn min(x: float, y: int) -> float +fn min(x: i32, y: i32) -> i32 +fn min(x: u16, y: u16) -> u16 +fn min(x: float, y: f32) -> float +fn min(x: f32, y: float) -> float +fn min(x: i128, y: i128) -> i128 +fn min(x: i16, y: i16) -> i16 +fn min(x: int, y: f32) -> f32 +fn min(x: float, y: float) -> float +fn min(x: i8, y: i8) -> i8 +``` + +
+
+ + +
+ +
+Return the string that is lexically smaller than the other string. +
+ + +
+
+
+
+

fn mixin

+ +```rust,ignore +fn mixin(map: Map, map2: Map) +``` + +
+
+ + +
+ +
+Add all property values of another object map into the object map. +Existing property values of the same names are replaced. +
+ + +
+
+
+
+

fn name

+ +```rust,ignore +fn name(fn_ptr: FnPtr) -> String +``` + +
+
+ + +
+ +
+Return the name of the function. +
+ + +
+
+
+
+

fn pad

+ +```rust,ignore +fn pad(string: String, len: int, padding: String) +fn pad(array: Array, len: int, item: ?) +fn pad(blob: Blob, len: int, value: int) +fn pad(string: String, len: int, character: char) +``` + +
+
+ + +
+ +
+Pad the string to at least the specified number of characters with the specified string. + +If `len` ≤ length of string, no padding is done. +
+ + +
+
+
+
+

fn parse_be_float

+ +```rust,ignore +fn parse_be_float(blob: Blob, range: RangeInclusive) -> float +fn parse_be_float(blob: Blob, range: Range) -> float +fn parse_be_float(blob: Blob, start: int, len: int) -> float +``` + +
+
+ +
+ +
+Parse the bytes within an inclusive `range` in the BLOB as a `FLOAT` +in big-endian byte order. + +* If number of bytes in `range` < number of bytes for `FLOAT`, zeros are padded. +* If number of bytes in `range` > number of bytes for `FLOAT`, extra bytes are ignored. +
+ +
+
+
+
+

fn parse_be_int

+ +```rust,ignore +fn parse_be_int(blob: Blob, range: RangeInclusive) -> int +fn parse_be_int(blob: Blob, range: Range) -> int +fn parse_be_int(blob: Blob, start: int, len: int) -> int +``` + +
+
+ +
+ +
+Parse the bytes within an inclusive `range` in the BLOB as an `INT` +in big-endian byte order. + +* If number of bytes in `range` < number of bytes for `INT`, zeros are padded. +* If number of bytes in `range` > number of bytes for `INT`, extra bytes are ignored. + +```rhai +let b = blob(); + +b += 1; b += 2; b += 3; b += 4; b += 5; + +let x = b.parse_be_int(1..=3); // parse three bytes + +print(x.to_hex()); // prints "0203040000...00" +``` +
+ +
+
+
+
+

fn parse_float

+ +```rust,ignore +fn parse_float(string: String) -> float +``` + +
+
+ + +
+ +
+Parse a string into a floating-point number. +
+ + +
+
+
+
+

fn parse_int

+ +```rust,ignore +fn parse_int(string: String) -> int +fn parse_int(string: String, radix: int) -> int +``` + +
+
+ + +
+ +
+Parse a string into an integer number. +
+ + +
+
+
+
+

fn parse_json

+ +```rust,ignore +fn parse_json(json: String) -> ? +``` + +
+
+ + +
+ +
+Parse a JSON string into a value. +
+ + +
+
+
+
+

fn parse_le_float

+ +```rust,ignore +fn parse_le_float(blob: Blob, range: RangeInclusive) -> float +fn parse_le_float(blob: Blob, range: Range) -> float +fn parse_le_float(blob: Blob, start: int, len: int) -> float +``` + +
+
+ +
+ +
+Parse the bytes within an inclusive `range` in the BLOB as a `FLOAT` +in little-endian byte order. + +* If number of bytes in `range` < number of bytes for `FLOAT`, zeros are padded. +* If number of bytes in `range` > number of bytes for `FLOAT`, extra bytes are ignored. +
+ +
+
+
+
+

fn parse_le_int

+ +```rust,ignore +fn parse_le_int(blob: Blob, range: RangeInclusive) -> int +fn parse_le_int(blob: Blob, range: Range) -> int +fn parse_le_int(blob: Blob, start: int, len: int) -> int +``` + +
+
+ +
+ +
+Parse the bytes within an inclusive `range` in the BLOB as an `INT` +in little-endian byte order. + +* If number of bytes in `range` < number of bytes for `INT`, zeros are padded. +* If number of bytes in `range` > number of bytes for `INT`, extra bytes are ignored. + +```rhai +let b = blob(); + +b += 1; b += 2; b += 3; b += 4; b += 5; + +let x = b.parse_le_int(1..=3); // parse three bytes + +print(x.to_hex()); // prints "040302" +``` +
+ +
+
+
+
+

fn pop

+ +```rust,ignore +fn pop(string: String) -> ? +fn pop(array: Array) -> ? +fn pop(blob: Blob) -> int +fn pop(string: String, len: int) -> String +``` + +
+
+ + +
+ +
+Remove the last character from the string and return it. + +If the string is empty, `()` is returned. +
+ + +
+
+
+
+

fn print

+ +```rust,ignore +fn print() -> String +fn print(string: String) -> String +fn print(item: ?) -> String +fn print(unit: ?) -> String +fn print(map: Map) -> String +fn print(number: f32) -> String +fn print(array: Array) -> String +fn print(character: char) -> String +fn print(number: float) -> String +fn print(value: bool) -> String +``` + +
+
+ +
+ + + +
+
+
+
+

fn push

+ +```rust,ignore +fn push(array: Array, item: ?) +fn push(blob: Blob, value: int) +``` + +
+
+ + +
+ +
+Add a new element, which is not another array, to the end of the array. + +If `item` is `Array`, then `append` is more specific and will be called instead. +
+ + +
+
+
+
+

fn range

+ +```rust,ignore +fn range(range: Range, step: u32) -> StepRange +fn range(range: Range, step: float) -> StepRange +fn range(from: i32, to: i32) -> Range +fn range(range: Range, step: int) -> StepRange +fn range(range: Range, step: i8) -> StepRange +fn range(from: int, to: int) -> Range +fn range(from: u128, to: u128) -> Range +fn range(from: u32, to: u32) -> Range +fn range(range: Range, step: u64) -> StepRange +fn range(from: u8, to: u8) -> Range +fn range(from: u64, to: u64) -> Range +fn range(from: i8, to: i8) -> Range +fn range(range: Range, step: i16) -> StepRange +fn range(from: i128, to: i128) -> Range +fn range(from: i16, to: i16) -> Range +fn range(range: Range, step: u128) -> StepRange +fn range(range: Range, step: u8) -> StepRange +fn range(range: Range, step: u16) -> StepRange +fn range(range: Range, step: i32) -> StepRange +fn range(range: Range, step: i128) -> StepRange +fn range(from: u16, to: u16) -> Range +fn range(from: i128, to: i128, step: i128) -> StepRange +fn range(from: u64, to: u64, step: u64) -> StepRange +fn range(from: int, to: int, step: int) -> StepRange +fn range(from: u16, to: u16, step: u16) -> StepRange +fn range(from: i32, to: i32, step: i32) -> StepRange +fn range(from: u32, to: u32, step: u32) -> StepRange +fn range(from: i8, to: i8, step: i8) -> StepRange +fn range(from: float, to: float, step: float) -> StepRange +fn range(from: u8, to: u8, step: u8) -> StepRange +fn range(from: u128, to: u128, step: u128) -> StepRange +fn range(from: i16, to: i16, step: i16) -> StepRange +``` + +
+
+ + +
+ +
+Return an iterator over an exclusive range, each iteration increasing by `step`. + +If `range` is reversed and `step` < 0, iteration goes backwards. + +Otherwise, if `range` is empty, an empty iterator is returned. +
+ + +
+
+
+
+

fn reduce

+ +```rust,ignore +fn reduce(array: Array, reducer: String) -> ? +fn reduce(array: Array, reducer: FnPtr) -> ? +fn reduce(array: Array, reducer: String, initial: ?) -> ? +fn reduce(array: Array, reducer: FnPtr, initial: ?) -> ? +``` + +
+
+ + + + +
+ +
+Reduce an array by iterating through all elements while applying a function named by `reducer`. +
+ + + + +
+
+
+
+

fn reduce_rev

+ +```rust,ignore +fn reduce_rev(array: Array, reducer: FnPtr) -> ? +fn reduce_rev(array: Array, reducer: String) -> ? +fn reduce_rev(array: Array, reducer: String, initial: ?) -> ? +fn reduce_rev(array: Array, reducer: FnPtr, initial: ?) -> ? +``` + +
+
+ + + +
+ +
+Reduce an array by iterating through all elements, in _reverse_ order, +while applying the `reducer` function. +
+ + + +
+
+
+
+

fn remove

+ +```rust,ignore +fn remove(string: String, character: char) +fn remove(array: Array, index: int) -> ? +fn remove(string: String, sub_string: String) +fn remove(map: Map, property: String) -> ? +fn remove(blob: Blob, index: int) -> int +``` + +
+
+ + +
+ +
+Remove all occurrences of a character from the string. +
+ + +
+
+
+
+

fn replace

+ +```rust,ignore +fn replace(string: String, find_character: char, substitute_character: char) +fn replace(string: String, find_string: String, substitute_character: char) +fn replace(string: String, find_character: char, substitute_string: String) +fn replace(string: String, find_string: String, substitute_string: String) +``` + +
+
+ + +
+ +
+Replace all occurrences of the specified character in the string with another character. +
+ + +
+
+
+
+

fn retain

+ +```rust,ignore +fn retain(array: Array, range: RangeInclusive) -> Array +fn retain(map: Map, filter: FnPtr) -> Map +fn retain(blob: Blob, range: RangeInclusive) -> Blob +fn retain(array: Array, range: Range) -> Array +fn retain(array: Array, filter: FnPtr) -> Array +fn retain(array: Array, filter: String) -> Array +fn retain(blob: Blob, range: Range) -> Blob +fn retain(array: Array, start: int, len: int) -> Array +fn retain(blob: Blob, start: int, len: int) -> Blob +``` + +
+
+ + +
+ +
+Remove all elements in the array not within an inclusive `range` and return them as a new array. +
+ + +
+
+
+
+

fn reverse

+ +```rust,ignore +fn reverse(blob: Blob) +fn reverse(array: Array) +``` + +
+
+ + +
+ +
+Reverse the BLOB. +
+ + +
+
+
+
+

fn round

+ +```rust,ignore +fn round(x: float) -> float +``` + +
+
+ +
+ +
+Return the nearest whole number closest to the floating-point number. +Rounds away from zero. +
+ +
+
+
+
+

fn set

+ +```rust,ignore +fn set(string: String, index: int, character: char) +fn set(map: Map, property: String, value: ?) +fn set(blob: Blob, index: int, value: int) +fn set(array: Array, index: int, value: ?) +``` + +
+
+ + +
+ +
+Set the `index` position in the string to a new `character`. + +* If `index` < 0, position counts from the end of the string (`-1` is the last character). +* If `index` < -length of string, the string is not modified. +* If `index` ≥ length of string, the string is not modified. +
+ + +
+
+
+
+

fn set_bit

+ +```rust,ignore +fn set_bit(value: int, bit: int, new_value: bool) +``` + +
+
+ + +
+ +
+Set the specified `bit` in the number if the new value is `true`. +Clear the `bit` if the new value is `false`. + +If `bit` < 0, position counts from the MSB (Most Significant Bit). +
+ + +
+
+
+
+

fn set_bits

+ +```rust,ignore +fn set_bits(value: int, range: Range, new_value: int) +fn set_bits(value: int, range: RangeInclusive, new_value: int) +fn set_bits(value: int, bit: int, bits: int, new_value: int) +``` + +
+
+ + +
+ +
+Replace an exclusive range of bits in the number with a new value. +
+ + +
+
+
+
+

fn set_tag

+ +```rust,ignore +fn set_tag(value: ?, tag: int) +``` + +
+
+ + +
+ +
+Set the _tag_ of a `Dynamic` value. +
+ + +
+
+
+
+

fn shift

+ +```rust,ignore +fn shift(array: Array) -> ? +fn shift(blob: Blob) -> int +``` + +
+
+ + +
+ +
+Remove the first element from the array and return it. + +If the array is empty, `()` is returned. +
+ + +
+
+
+
+

fn sign

+ +```rust,ignore +fn sign(x: float) -> int +fn sign(x: i8) -> int +fn sign(x: int) -> int +fn sign(x: i32) -> int +fn sign(x: i128) -> int +fn sign(x: i16) -> int +fn sign(x: f32) -> int +``` + +
+
+ +
+ +
+Return the sign (as an integer) of the floating-point number according to the following: + +* `0` if the number is zero +* `1` if the number is positive +* `-1` if the number is negative +
+ +
+
+
+
+

fn sin

+ +```rust,ignore +fn sin(x: float) -> float +``` + +
+
+ +
+ +
+Return the sine of the floating-point number in radians. +
+ +
+
+
+
+

fn sinh

+ +```rust,ignore +fn sinh(x: float) -> float +``` + +
+
+ +
+ +
+Return the hyperbolic sine of the floating-point number in radians. +
+ +
+
+
+
+

fn sleep

+ +```rust,ignore +fn sleep(seconds: float) +fn sleep(seconds: int) +``` + +
+
+ + +
+ +
+Block the current thread for a particular number of `seconds`. +
+ + +
+
+
+
+

fn some

+ +```rust,ignore +fn some(array: Array, filter: FnPtr) -> bool +fn some(array: Array, filter: String) -> bool +``` + +
+
+ + + + +
+ +
+Return `true` if any element in the array that returns `true` when applied the `filter` function. +
+ + + + +
+
+
+
+

fn sort

+ +```rust,ignore +fn sort(array: Array) +fn sort(array: Array, comparer: String) +fn sort(array: Array, comparer: FnPtr) +``` + +
+
+ + + +
+ +
+Sort the array. + +All elements in the array must be of the same data type. +
+ + + +
+
+
+
+

fn splice

+ +```rust,ignore +fn splice(blob: Blob, range: Range, replace: Blob) +fn splice(array: Array, range: RangeInclusive, replace: Array) +fn splice(blob: Blob, range: RangeInclusive, replace: Blob) +fn splice(array: Array, range: Range, replace: Array) +fn splice(blob: Blob, start: int, len: int, replace: Blob) +fn splice(array: Array, start: int, len: int, replace: Array) +``` + +
+
+ + +
+ +
+Replace an exclusive `range` of the BLOB with another BLOB. +
+ + +
+
+
+
+

fn split

+ +```rust,ignore +fn split(string: String) -> Array +fn split(array: Array, index: int) -> Array +fn split(string: String, delimiter: String) -> Array +fn split(string: String, delimiter: char) -> Array +fn split(blob: Blob, index: int) -> Blob +fn split(string: String, index: int) -> Array +fn split(string: String, delimiter: String, segments: int) -> Array +fn split(string: String, delimiter: char, segments: int) -> Array +``` + +
+
+ + +
+ +
+Split the string into segments based on whitespaces, returning an array of the segments. +
+ + +
+
+
+
+

fn split_rev

+ +```rust,ignore +fn split_rev(string: String, delimiter: char) -> Array +fn split_rev(string: String, delimiter: String) -> Array +fn split_rev(string: String, delimiter: String, segments: int) -> Array +fn split_rev(string: String, delimiter: char, segments: int) -> Array +``` + +
+
+ + +
+ +
+Split the string into segments based on a `delimiter` character, returning an array of +the segments in _reverse_ order. +
+ + +
+
+
+
+

fn sqrt

+ +```rust,ignore +fn sqrt(x: float) -> float +``` + +
+
+ +
+ +
+Return the square root of the floating-point number. +
+ +
+
+
+
+

fn start

+ +```rust,ignore +fn start(range: RangeInclusive) -> int +fn start(range: Range) -> int +``` + +
+
+ +
+ +
+Return the start of the inclusive range. +
+ +
+
+
+
+

fn starts_with

+ +```rust,ignore +fn starts_with(string: String, match_string: String) -> bool +``` + +
+
+ + +
+ +
+Return `true` if the string starts with a specified string. +
+ + +
+
+
+
+

fn sub_string

+ +```rust,ignore +fn sub_string(string: String, range: Range) -> String +fn sub_string(string: String, range: RangeInclusive) -> String +fn sub_string(string: String, start: int) -> String +fn sub_string(string: String, start: int, len: int) -> String +``` + +
+
+ + +
+ +
+Copy an exclusive range of characters from the string and return it as a new string. +
+ + +
+
+
+
+

fn tag

+ +```rust,ignore +fn tag(value: ?) -> int +``` + +
+
+ + +
+ +
+Return the _tag_ of a `Dynamic` value. +
+ + +
+
+
+
+

fn take

+ +```rust,ignore +fn take(value: ?) -> ? +``` + +
+
+ + +
+ +
+Take ownership of the data in a `Dynamic` value and return it. +The data is _NOT_ cloned. + +The original value is replaced with `()`. +
+ + +
+
+
+
+

fn tan

+ +```rust,ignore +fn tan(x: float) -> float +``` + +
+
+ +
+ +
+Return the tangent of the floating-point number in radians. +
+ +
+
+
+
+

fn tanh

+ +```rust,ignore +fn tanh(x: float) -> float +``` + +
+
+ +
+ +
+Return the hyperbolic tangent of the floating-point number in radians. +
+ +
+
+
+
+

fn timestamp

+ +```rust,ignore +fn timestamp() -> Instant +``` + +
+
+ + +
+ +
+Create a timestamp containing the current system time. +
+ + +
+
+
+
+

fn to_array

+ +```rust,ignore +fn to_array(blob: Blob) -> Array +``` + +
+
+ + +
+ +
+Convert the BLOB into an array of integers. +
+ + +
+
+
+
+

fn to_binary

+ +```rust,ignore +fn to_binary(value: i8) -> String +fn to_binary(value: int) -> String +fn to_binary(value: u64) -> String +fn to_binary(value: u16) -> String +fn to_binary(value: u128) -> String +fn to_binary(value: u32) -> String +fn to_binary(value: i32) -> String +fn to_binary(value: u8) -> String +fn to_binary(value: i128) -> String +fn to_binary(value: i16) -> String +``` + +
+
+ +
+ +
+Convert the `value` into a string in binary format. +
+ +
+
+
+
+

fn to_blob

+ +```rust,ignore +fn to_blob(string: String) -> Blob +``` + +
+
+ + +
+ +
+Convert the string into an UTF-8 encoded byte-stream as a BLOB. +
+ + +
+
+
+
+

fn to_chars

+ +```rust,ignore +fn to_chars(string: String) -> Array +``` + +
+
+ + +
+ +
+Return an array containing all the characters of the string. +
+ + +
+
+
+
+

fn to_debug

+ +```rust,ignore +fn to_debug(value: bool) -> String +fn to_debug(number: float) -> String +fn to_debug(character: char) -> String +fn to_debug(f: FnPtr) -> String +fn to_debug(array: Array) -> String +fn to_debug(map: Map) -> String +fn to_debug(unit: ?) -> String +fn to_debug(number: f32) -> String +fn to_debug(item: ?) -> String +fn to_debug(string: String) -> String +``` + +
+
+ +
+ +
+Convert the boolean value into a string in debug format. +
+ +
+
+
+
+

fn to_degrees

+ +```rust,ignore +fn to_degrees(x: float) -> float +``` + +
+
+ +
+ +
+Convert radians to degrees. +
+ +
+
+
+
+

fn to_float

+ +```rust,ignore +fn to_float() +fn to_float() +fn to_float() +fn to_float() +fn to_float() +fn to_float() +fn to_float() +fn to_float() +fn to_float(x: f32) -> float +fn to_float() +fn to_float() +fn to_float() +``` + +
+
+ +
+ +
+Convert the 32-bit floating-point number to 64-bit. +
+ +
+
+
+
+

fn to_hex

+ +```rust,ignore +fn to_hex(value: u32) -> String +fn to_hex(value: u128) -> String +fn to_hex(value: i8) -> String +fn to_hex(value: u64) -> String +fn to_hex(value: u16) -> String +fn to_hex(value: int) -> String +fn to_hex(value: i16) -> String +fn to_hex(value: u8) -> String +fn to_hex(value: i32) -> String +fn to_hex(value: i128) -> String +``` + +
+
+ +
+ +
+Convert the `value` into a string in hex format. +
+ +
+
+
+
+

fn to_int

+ +```rust,ignore +fn to_int() +fn to_int(x: f32) -> int +fn to_int() +fn to_int() +fn to_int() +fn to_int() +fn to_int(x: float) -> int +fn to_int() +fn to_int() +fn to_int() +fn to_int() +fn to_int() +fn to_int() +``` + +
+
+ +
+ +
+Convert the floating-point number into an integer. +
+ +
+
+
+
+

fn to_json

+ +```rust,ignore +fn to_json(map: Map) -> String +``` + +
+
+ + + + +
+ +
+Return the JSON representation of the object map. +
+ + + + +
+
+
+
+

fn to_lower

+ +```rust,ignore +fn to_lower(character: char) -> char +fn to_lower(string: String) -> String +``` + +
+
+ + +
+ +
+Convert the character to lower-case and return it as a new character. +
+ + +
+
+
+
+

fn to_octal

+ +```rust,ignore +fn to_octal(value: i16) -> String +fn to_octal(value: i128) -> String +fn to_octal(value: i32) -> String +fn to_octal(value: u8) -> String +fn to_octal(value: u32) -> String +fn to_octal(value: u128) -> String +fn to_octal(value: u16) -> String +fn to_octal(value: u64) -> String +fn to_octal(value: int) -> String +fn to_octal(value: i8) -> String +``` + +
+
+ +
+ +
+Convert the `value` into a string in octal format. +
+ +
+
+
+
+

fn to_radians

+ +```rust,ignore +fn to_radians(x: float) -> float +``` + +
+
+ +
+ +
+Convert degrees to radians. +
+ +
+
+
+
+

fn to_string

+ +```rust,ignore +fn to_string(array: Array) -> String +fn to_string(number: f32) -> String +fn to_string(map: Map) -> String +fn to_string(unit: ?) -> String +fn to_string(item: ?) -> String +fn to_string(string: String) -> String +fn to_string(value: bool) -> String +fn to_string(number: float) -> String +fn to_string(character: char) -> String +``` + +
+
+ +
+ +
+Convert the array into a string. +
+ +
+
+
+
+

fn to_upper

+ +```rust,ignore +fn to_upper(character: char) -> char +fn to_upper(string: String) -> String +``` + +
+
+ + +
+ +
+Convert the character to upper-case and return it as a new character. +
+ + +
+
+
+
+

fn trim

+ +```rust,ignore +fn trim(string: String) +``` + +
+
+ + +
+ +
+Remove whitespace characters from both ends of the string. +
+ + +
+
+
+
+

fn truncate

+ +```rust,ignore +fn truncate(array: Array, len: int) +fn truncate(blob: Blob, len: int) +fn truncate(string: String, len: int) +``` + +
+
+ + +
+ +
+Cut off the array at the specified length. + +* If `len` ≤ 0, the array is cleared. +* If `len` ≥ length of array, the array is not truncated. +
+ + +
+
+
+
+

get/set u128.is_even

+ +```rust,ignore +get u128.is_even -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

get/set u128.is_odd

+ +```rust,ignore +get u128.is_odd -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

get/set u128.is_zero

+ +```rust,ignore +get u128.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

get/set u16.is_even

+ +```rust,ignore +get u16.is_even -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

get/set u16.is_odd

+ +```rust,ignore +get u16.is_odd -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

get/set u16.is_zero

+ +```rust,ignore +get u16.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

get/set u32.is_even

+ +```rust,ignore +get u32.is_even -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

get/set u32.is_odd

+ +```rust,ignore +get u32.is_odd -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

get/set u32.is_zero

+ +```rust,ignore +get u32.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

get/set u64.is_even

+ +```rust,ignore +get u64.is_even -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

get/set u64.is_odd

+ +```rust,ignore +get u64.is_odd -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

get/set u64.is_zero

+ +```rust,ignore +get u64.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

get/set u8.is_even

+ +```rust,ignore +get u8.is_even -> bool +``` + +
+
+ +
+ +
+Return true if the number is even. +
+ +
+
+
+
+

get/set u8.is_odd

+ +```rust,ignore +get u8.is_odd -> bool +``` + +
+
+ +
+ +
+Return true if the number is odd. +
+ +
+
+
+
+

get/set u8.is_zero

+ +```rust,ignore +get u8.is_zero -> bool +``` + +
+
+ +
+ +
+Return true if the number is zero. +
+ +
+
+
+
+

fn values

+ +```rust,ignore +fn values(map: Map) -> Array +``` + +
+
+ + +
+ +
+Return an array with all the property values in the object map. +
+ + +
+
+
+
+

fn write_ascii

+ +```rust,ignore +fn write_ascii(blob: Blob, range: Range, string: String) +fn write_ascii(blob: Blob, range: RangeInclusive, string: String) +fn write_ascii(blob: Blob, start: int, len: int, string: String) +``` + +
+
+ +
+ +
+Write an ASCII string to the bytes within an exclusive `range` in the BLOB. + +Each ASCII character encodes to one single byte in the BLOB. +Non-ASCII characters are ignored. + +* If number of bytes in `range` < length of `string`, extra bytes in `string` are not written. +* If number of bytes in `range` > length of `string`, extra bytes in `range` are not modified. + +```rhai +let b = blob(8); + +b.write_ascii(1..5, "hello, world!"); + +print(b); // prints "[0068656c6c000000]" +``` +
+ +
+
+
+
+

fn write_be

+ +```rust,ignore +fn write_be(blob: Blob, range: Range, value: float) +fn write_be(blob: Blob, range: RangeInclusive, value: float) +fn write_be(blob: Blob, range: RangeInclusive, value: int) +fn write_be(blob: Blob, range: Range, value: int) +fn write_be(blob: Blob, start: int, len: int, value: int) +fn write_be(blob: Blob, start: int, len: int, value: float) +``` + +
+
+ +
+ +
+Write a `FLOAT` value to the bytes within an exclusive `range` in the BLOB +in big-endian byte order. + +* If number of bytes in `range` < number of bytes for `FLOAT`, extra bytes in `FLOAT` are not written. +* If number of bytes in `range` > number of bytes for `FLOAT`, extra bytes in `range` are not modified. +
+ +
+
+
+
+

fn write_le

+ +```rust,ignore +fn write_le(blob: Blob, range: Range, value: int) +fn write_le(blob: Blob, range: RangeInclusive, value: float) +fn write_le(blob: Blob, range: RangeInclusive, value: int) +fn write_le(blob: Blob, range: Range, value: float) +fn write_le(blob: Blob, start: int, len: int, value: float) +fn write_le(blob: Blob, start: int, len: int, value: int) +``` + +
+
+ +
+ +
+Write an `INT` value to the bytes within an exclusive `range` in the BLOB +in little-endian byte order. + +* If number of bytes in `range` < number of bytes for `INT`, extra bytes in `INT` are not written. +* If number of bytes in `range` > number of bytes for `INT`, extra bytes in `range` are not modified. + +```rhai +let b = blob(8); + +b.write_le_int(1..3, 0x12345678); + +print(b); // prints "[0078560000000000]" +``` +
+ +
+
+
+
+

fn write_utf8

+ +```rust,ignore +fn write_utf8(blob: Blob, range: Range, string: String) +fn write_utf8(blob: Blob, range: RangeInclusive, string: String) +fn write_utf8(blob: Blob, start: int, len: int, string: String) +``` + +
+
+ +
+ +
+Write a string to the bytes within an exclusive `range` in the BLOB in UTF-8 encoding. + +* If number of bytes in `range` < length of `string`, extra bytes in `string` are not written. +* If number of bytes in `range` > length of `string`, extra bytes in `range` are not modified. + +```rhai +let b = blob(8); + +b.write_utf8(1..5, "朝には紅顔ありて夕べには白骨となる"); + +print(b); // prints "[00e69c9de3000000]" +``` +
+ +
+
+
+
+

fn zip

+ +```rust,ignore +fn zip(array1: Array, array2: Array, map: FnPtr) -> Array +``` + +
+
+ + + +
+ +
+Iterate through all elements in two arrays, applying a `mapper` function to them, +and return a new array containing the results. +
+ + + +
+
+
diff --git a/tools/generate-rhai-docs/src/main.rs b/tools/generate-rhai-docs/src/main.rs new file mode 100644 index 0000000..b97e780 --- /dev/null +++ b/tools/generate-rhai-docs/src/main.rs @@ -0,0 +1,63 @@ +use rhai::{Engine, module_resolvers::StaticModuleResolver}; +use std::{env, fs, path::Path}; +use iirhai::providers; +use rhai_autodocs::{export::options, generate::mdbook}; + +fn generate_docs(engine: &Engine, path: &str, filename: &str, include_std: bool) { + let docs = options() + .include_standard_packages(include_std) + .export(engine) + .expect("failed to generate documentation"); + + // Generate markdown documentation content + let docs_content = mdbook().generate(&docs).unwrap(); + + if docs_content.is_empty() { + eprintln!("No documentation generated for {}.", filename); + return; + } + + // Combine all module docs into one + let full_docs = docs_content.into_iter().map(|(_, doc)| doc).collect::>().join("\n"); + + // Write documentation to markdown file + let file_path = Path::new(path).join(format!("{}.md", filename)); + fs::write(&file_path, full_docs).expect("failed to write documentation"); + println!("Documentation generated at: {}", file_path.display()); +} + +fn main() { + let args: Vec = env::args().collect(); + let path = if args.len() > 1 { + &args[1] + } else { + "./docs/src/modules" + }; + + // engine/resolver + let engine = Engine::new(); + let mut resolver = StaticModuleResolver::new(); + + // Generate global.md (full docs) + generate_docs(&engine, path, "global", true); + + // Generate stdlib.md docs (custom stdlib) + resolver.clear(); + let mut engine = Engine::new(); // recreate engine to reset state + providers::register_stdlib(&mut resolver); + for (module_name, module) in resolver.iter() { + engine.register_static_module(module_name, module.clone()); + } + generate_docs(&engine, path, "stdlib", false); + + // Generate apilib.md docs + resolver.clear(); + let mut engine = Engine::new(); // recreate engine to reset state + providers::register_apilib(&mut resolver); + for (module_name, module) in resolver.iter() { + engine.register_static_module(module_name, module.clone()); + } + generate_docs(&engine, path, "apilib", false); + + println!("Docs generation completed."); +}