#value #universal #pest #type #properties

path-value

Universal type and access property(s) by path

2 releases

0.1.5 Jul 24, 2021
0.1.4 Aug 21, 2020

#1126 in Data structures


Used in ddns-rs

Custom license

140KB
2K SLoC

path-value

Rust Build Status Crate Status Docs Status

path-value is a Rust universal type library used to access property(s) in Value by path.

Quick start

use path_value::Value;

fn main() {
    let mut value_origin = Value::default();

    value_origin.set("/test/bool", true).unwrap();
    value_origin.set("/test/str", "i am string").unwrap();

    println!("{}", value_origin.get::<bool, _, _>("/test/bool").unwrap().unwrap());
    println!("{}", value_origin.get::<String, _, _>("/test/str").unwrap().unwrap());

    println!("\nAfter merge\n");

    let mut value_new = Value::default();

    value_new.set("/test/bool", false).unwrap();
    value_new.set("/test/i32", 1000_i32).unwrap();

    value_origin.merge(value_new).unwrap();

    println!("{}", value_origin.get::<bool, _, _>("/test/bool").unwrap().unwrap());
    println!("{}", value_origin.get::<String, _, _>("/test/str").unwrap().unwrap());
    println!("{}", value_origin.get::<i32, _, _>("/test/i32").unwrap().unwrap());
}

Path grammar

/<path>/<path>[index]

Path Grammar

<path>[index]

represents access to an array of elements

Documentation

License

MIT

Dependencies

~2.6–3.5MB
~72K SLoC