Expand description
A crate with helper utilities for managing shared configuration in Storm workspaces.
This crate provides a set of tools for working with configuration files and environment variables in a consistent way. It supports multiple file formats, including JSON, YAML, TOML, and XML, and allows for easy merging and overriding of configuration values from different sources.
§Features
- The
WorkspaceConfigstruct representing the universal workspace configuration definition. - Support for multiple configuration file formats (JSON, YAML, TOML, XML).
- Environment variable overrides.
- Hierarchical configuration with support for nested structures.
- Type-safe access to configuration values.
- Custom configuration sources via the
Sourcetrait.
§Example
use storm_config::{Config, File, FileFormat, FileSourceFile, Format};
// Create a new configuration instance
let mut config = Config::default();
// Merge a JSON configuration file
let file = File::new("config.json", FileFormat::Json);
config.merge(file).unwrap();
// Access a configuration value
let db_host: String = config.get("database.host").unwrap();
println!("Database host: {}", db_host);For more information, please refer to the documentation.
Re-exports§
pub use crate::builder::ConfigBuilder;
Modules§
Structs§
- Config
- A prioritized configuration repository. It maintains a set of configuration sources, fetches values to populate those, and provides them according to the source’s priority.
- Environment
- An environment source collects a dictionary of environment variables values into a hierarchical config Value type. We have to be aware how the config tree is created from the environment dictionary, therefore we are mindful about prefixes for the environment keys, level separators, encoding form (kebab, snake case) etc.
- File
- A configuration source backed up by a file.
- File
Source File - Describes a file sourced from a file
- File
Source String - Describes a file sourced from a string
- Value
- A configuration value.
Enums§
- Case
- Defines the type of casing a string can be.
- Config
Error - Represents all possible errors that can occur when working with configuration.
- File
Format - File formats provided by the library.
- Value
Kind - Underlying kind of the configuration value.
Traits§
- Async
Source - Describes a generic source of configuration properties capable of using an async runtime.
- File
Source - Describes where the file is sourced
- File
Stored Format - An extension of
Formattrait. - Format
- Describes a format of configuration source data
- Source
- Describes a generic source of configuration properties.