Skip to content

Nested structures storing constants, holding mutable values and values fetched from API, accessible by string path such as 'root/constants/const-1' or 'root/api/api-value-1'

License

Notifications You must be signed in to change notification settings

a-givertzman/rust-nested-value

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Nested Value

Nested structures stores the following values ​​inside:

  • ConstValue - constant values
  • MutValue - mutable values
  • FetchValue - values fetched from API
  • MultiValue - collection, nested structire

Any value present in the structure can be accessed by string path
such as 'root/constants/const-1' or 'root/api/api-value-1'

Example:

    let value = ConstValue::new(Value::Null);
    println!("const value: {:?}", value.get());

    let value = ConstValue::new(12345.6789012345);
    println!("const value: {:?}", value.get());

    let mut flags = MultiValue::new([
        ("bool-flags", Box::new(MultiValue::new([
            ("flag-1", Box::new(ConstValue::new(true))),
            ("flag-2", Box::new(MutValue::new(false))),
        ]))),
    ]);
    let key = "bool-flags/flag-1";
    println!("flag: {:?}", flags.get(key));
    flags
        .store("example", key, true)
        .unwrap_or_else(|err| println!("example | Store error: {}", err));
    println!("flag: {:?}", flags.get(key));

About

Nested structures storing constants, holding mutable values and values fetched from API, accessible by string path such as 'root/constants/const-1' or 'root/api/api-value-1'

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages