path-value 0.1.5

Universal type and access property(s) by path
Documentation

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