Crate storm_config

Crate storm_config 

Source
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 WorkspaceConfig struct 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 Source trait.

§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§

builder
types
workspace_config

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.
FileSourceFile
Describes a file sourced from a file
FileSourceString
Describes a file sourced from a string
Value
A configuration value.

Enums§

Case
Defines the type of casing a string can be.
ConfigError
Represents all possible errors that can occur when working with configuration.
FileFormat
File formats provided by the library.
ValueKind
Underlying kind of the configuration value.

Traits§

AsyncSource
Describes a generic source of configuration properties capable of using an async runtime.
FileSource
Describes where the file is sourced
FileStoredFormat
An extension of Format trait.
Format
Describes a format of configuration source data
Source
Describes a generic source of configuration properties.

Type Aliases§

Map