👎Deprecated since 2.0.1: use cfgmatic-source crate instead, which provides a unified configuration source API
Expand description
Configuration file discovery and reading with multiple format support.
DEPRECATED: This crate is deprecated since version 2.0.1.
Use cfgmatic-source instead, which provides a more comprehensive
and unified API for configuration source management.
§Migration Guide
This crate has been superseded by cfgmatic-source. Below is a guide
for migrating your code to the new API.
§Crate Replacement
Replace in Cargo.toml:
// Old (deprecated)
[dependencies]
cfgmatic-files = "2.0"
// New
[dependencies]
cfgmatic-source = "2.0"§Type Mappings
| Old (cfgmatic-files) | New (cfgmatic-source) | Notes |
|---|---|---|
ConfigFile | FileSource | File-based configuration source |
ConfigFiles | CompositeSource | Multiple sources with priority |
FileFinder | Loader with FileConfig | Unified loading interface |
Mergeable | Merge trait from cfgmatic-merge | Direct merge trait |
Format | cfgmatic_source::Format | Same enum, new location |
FileError | SourceError | Unified error type |
§API Examples
§Loading a Single File
ⓘ
// Old API (deprecated)
use cfgmatic_files::FileFinder;
let files = FileFinder::new("myapp").find()?;
let config: Config = files.first().unwrap().parse()?;
// New API
use cfgmatic_source::prelude::*;
let config: Config = FileSource::new("config.toml").load()?.parse_as()?;§Loading with Multiple Sources
ⓘ
// Old API (deprecated)
use cfgmatic_files::load_merged;
let config: Config = load_merged("myapp")?;
// New API
use cfgmatic_source::prelude::*;
let source = CompositeSource::new()
.with_source(FileSource::new("config.toml"), SourcePriority::High)
.with_source(EnvSource::new("APP"), SourcePriority::Low);
let config: Config = source.load()?.parse_as()?;§Finding Config Files
ⓘ
// Old API (deprecated)
use cfgmatic_files::{FileFinder, find_files};
let files = find_files("myapp")?;
// New API
use cfgmatic_source::prelude::*;
let loader = Loader::new()
.with_source(FileConfig::new().app_name("myapp"));
let result = loader.load()?;§Features
The new cfgmatic-source crate supports all features from this crate:
toml- TOML format support (default)json- JSON format support (default)yaml- YAML format supportenv- Environment variable sourcesasync- Async loading supportremote- Remote HTTP/HTTPS sourceswatch- File watching support
§Transition Period
During the transition period, this crate re-exports types from
cfgmatic-source for convenience. However, new code should use
cfgmatic-source directly.
Modules§
- prelude
Deprecated - Convenience functions for common operations.
Structs§
- Config
Candidate - Information about a configuration path candidate.
- Config
File Deprecated - A discovered configuration file.
- Config
File Rule - Rule for finding a single configuration file.
- Config
Files Deprecated - A collection of configuration files sorted by priority.
- Config
Rule Set - Set of configuration file rules.
- File
Finder Deprecated - Builder for configuring file search.
- File
Finder State Deprecated - Stateful file finder after configuration.
- File
Source - File-based configuration source.
- Fragment
Rule - Rule for configuration fragment directories (conf.d style).
- Load
Result - Re-export of cfgmatic-source types for migration convenience. Result of loading configuration from multiple sources.
- Loader
- Re-export of cfgmatic-source types for migration convenience. Service for loading configuration from sources.
- Loader
Builder - Re-export of cfgmatic-source types for migration convenience.
Builder for
Loader. - Rule
Based Discovery - Result of rule-based configuration discovery.
- Rule
Based Loader Deprecated - Configuration loader with rule-based discovery.
- Source
Metadata - Re-export of cfgmatic-source types for migration convenience. Metadata about a configuration source.
Enums§
- Array
Merge Strategy - Strategy for merging arrays.
- Config
Tier - Configuration tier represents the priority level of a configuration source.
- File
Error Deprecated - Errors that can occur when working with configuration files.
- Format
Deprecated - Supported configuration file formats.
- Merge
Behavior - How to handle conflicting values during merge.
- Source
Error - Re-export of cfgmatic-source types for migration convenience. Error type for source operations.
- Source
Kind - Re-export of cfgmatic-source types for migration convenience. Kind of configuration source.
- Tier
Search Mode - How to search tiers for configuration files.
Traits§
- Mergeable
Deprecated - Trait for types that can be merged.
- Source
- Re-export of cfgmatic-source types for migration convenience. A configuration source.
Functions§
- config_
exists Deprecated - Check if a configuration exists for the application.
- find_
files Deprecated - Find configuration files using a simple API.
- find_
first_ file Deprecated - Find the first configuration file.
- find_
with_ format Deprecated - Find configuration files with a specific format.
- load_
first Deprecated - Load configuration from the first found file.
- load_
merged Deprecated - Load and merge configuration from all found files.
- load_
with_ rules Deprecated - Load configuration using rule-based discovery.
Type Aliases§
- Merge
Options Deprecated - Options for configuration merging.
- Result
Deprecated - Result type alias for file operations.