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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/config/layers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,15 @@ impl Layers {

Ok(None)
}

/// Iterate over the individual layers
///
/// This function returns an iterator that can be used to iterate over the individual layers of
/// the configuration.
///
/// This is useful if you want to access all values of each layer (even the shadowed ones) for
/// example for debug analysis of the loaded configuration values.
pub fn iter(&self) -> impl Iterator<Item = &ConfigObject> {
self.0.iter()
}
}
5 changes: 5 additions & 0 deletions src/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ impl ConfigObject {
Ok(None)
}
}

/// Get the configuration element that the object wraps
pub fn element(&self) -> &dyn ConfigElement {
&*self.element
}
}

#[derive(Debug, thiserror::Error)]
Expand Down