Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Layer iteration and ConfigObject access #83

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

matthiasbeyer
Copy link
Owner

Closes #82

@LukeMathWalker can you check whether this suffices your needs?

@LukeMathWalker
Copy link

LukeMathWalker commented May 18, 2023

A bit tricky to determine since I'm not super familiar with the API structure here.
I'm assuming that a ConfigObject would wrap around an entire JSON value/environment variable. From that point onwards you need a visitor that traverses the wrapped value—it looks like you expose enough to make that possible, but I'd need to play around with it to find out.

From a quick look at the API is also not clear to me how it is going to square out with bindings to an existing struct via serde?

@matthiasbeyer
Copy link
Owner Author

I'm assuming that a ConfigObject would wrap around an entire JSON value/environment variable.

Yes, a ConfigObject is essentially a complete configuration that is loaded from a source and is then one layer in the layered configuration.
From there you can retrieve a &dyn ConfigElement which is one element of your configuration. For example a boolean, a integer... or a list or a table... It could be a serde_json::Value, or a toml::Value... or something different.
And that can be used to traverse the whole tree of configuration settings from that one ConfigObject/Layer.

ConfigElement is implemented on serde_json::Value for example (https://github.com/matthiasbeyer/config-rs-ng/blob/master/src/element/json.rs). That would be the "backend" of the config-rs-ng crate so to speak.

Signed-off-by: Matthias Beyer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Loading report
2 participants