Expand description
Cargoβs layered config system
This crate is maintained by the Cargo team, primarily for use by Cargo and not intended for external use (except as a transitive dependency). This crate may make major changes to its APIs or be deprecated without warning.
ConfigLoader discovers and loads config files as ConfigStore layers.
ConfigReader::get is the primary way to load schemas.
Β§Example
let shell = // ...
let current_dir = // ...
let cargo_home = // ...
let loader = cargo_util_config::ConfigLoader::new(&shell, ¤t_dir, &cargo_home);
let layers = loader.load_layers(¤t_dir)?;
let config = cargo_util_config::ConfigStore::from_layers(layers)?;
let env = // ...
let reader = cargo_util_config::ConfigReader::new(&shell)
.config(&config)
.env(&env);
use cargo_util_config::schema::CargoBuildConfig;
let build_key = cargo_util_config::ConfigKey::from_parts(["build"]);
let build = reader.get::<CargoBuildConfig>(build_key)?;Re-exportsΒ§
pub use config_store::ConfigStore;pub use config_value::ConfigValue;pub use definition::Definition;pub use definition::Origin;pub use definition::Scope;pub use env::Env;pub use error::ConfigError;pub use key::ConfigKey;pub use loader::ConfigLoader;pub use reader::ConfigReader;pub use reader::expected;pub use value::OptValue;pub use value::Value;pub(crate) use config_value::is_nonmergeable_list;πpub(crate) use key::ArrayItemKeyPath;π
ModulesΒ§
- config_
store π - config_
value π ConfigValuerepresents Cargo configuration values loaded from TOML.- de π
- Deserialization for converting
ConfigValueinstances to target types. - definition π
- env π
- Encapsulates snapshotting of environment variables.
- error π
- key π
- loader π
- Config file discovery,
includehandling, and--configparsing - reader π
- schema
- Cargo configuration schemas.
- value π
- Deserialization of a
Value<T>type which tracks where it was deserialized from.
ConstantsΒ§
- CRATES_
IO_ πREGISTRY