| Crates.io | anyval |
| lib.rs | anyval |
| version | 0.1.0 |
| created_at | 2025-11-28 15:23:10.804205+00 |
| updated_at | 2025-11-28 15:23:10.804205+00 |
| description | A lightweight, dynamically‑typed value container for Rust that works like a scripting language. |
| homepage | |
| repository | https://github.com/fereidani/anyval |
| max_upload_size | |
| id | 1955491 |
| size | 58,182 |
A lightweight, dynamically‑typed value container for Rust.
anyval provides Map, Array, and Value types that let you store heterogeneous data (numbers, strings, booleans, nested maps/arrays) with a simple, ergonomic API. It’s ideal for configuration handling, scripting, or any situation where you need a flexible data model without pulling in a full‑blown JSON library.
Value can hold floats, ints, bools, strings, maps, arrays, or None.serde integration for (de)serialization.map! and array! for quick literal construction.to_json / from_json behind the json feature.# Add anyval with the desired features
cargo add anyval
# Add anyval without the default features (no json & serde)
cargo add anyval --no-default-features
use anyval::{map, array, Value};
fn main() {
// Build a map with mixed types
let cfg = map! {
"host" => "localhost",
"port" => 8080,
"debug" => true,
"paths" => array!["/api", "/static"],
};
// Access values
println!("Host: {}", cfg["host"].as_str());
println!("Port: {}", cfg["port"].as_int());
// Serialize to JSON (requires the `json` feature)
#[cfg(feature = "json")]
println!("JSON: {}", cfg.to_json().unwrap());
}
For full API details, examples, and feature flags, see the crate documentation: