Struct stackedconfig::ConfigStack
[−]
[src]
pub struct ConfigStack { /* fields omitted */ }
Combines multiple serde_json::Value
objects together so they can be
queried as a single, nested object.
Supports using a custom separator if desired for path style queries.
Defaults to a forward slash /
.
Methods
impl ConfigStack
[src]
fn new() -> ConfigStack
Create a new ConfigStack
fn with_path_sep(self, sep: char) -> ConfigStack
Returns a new ConfigStack
with the given separator
let conf = ConfigStack::new().with_path_sep('.').push(v1).push(v2); let val = conf.get("foo.bar.baz");
fn push(self, config: Value) -> ConfigStack
Adds a new configuration value to the stack. The added value becomes the highest priority value on the stack.
fn pop(self) -> Option<Value>
Removes the top level configuration from the stack and returns it. The
opposite of push
. If no configurations are on the stack then None
is returned.
fn get(&self, path: &str) -> Lookup
Looks up a value at the given path
conf.get("foo/bar/baz") -> Lookup::Found(Value::Bool(true)) conf.get("foo/bar/qux") -> Lookup::Missing
fn get_parts(&self, path_parts: Vec<String>) -> Lookup
Looks up a value at the given path where the path is a Vec<String>
. No
parsing is performed on the path parts, so this method will not split on
the path separator.