pub trait ConfigTrait: Sized {
// Required methods
fn load(sources: &[ConfigSource]) -> Result<Self, ConfigError>;
fn field_meta() -> &'static [ConfigFieldMeta];
}Expand description
Trait implemented by #[derive(Config)] structs.
Provides config loading from multiple sources with a defined precedence order, and field introspection for tooling.
Required Methods§
Sourcefn load(sources: &[ConfigSource]) -> Result<Self, ConfigError>
fn load(sources: &[ConfigSource]) -> Result<Self, ConfigError>
Load this config by applying sources in order (later sources win).
The conventional source slice is:
ⓘ
&[
ConfigSource::Defaults,
ConfigSource::File(path),
ConfigSource::Env { prefix: Some("APP".into()) },
]Sourcefn field_meta() -> &'static [ConfigFieldMeta]
fn field_meta() -> &'static [ConfigFieldMeta]
Return metadata for all fields in this config struct.
Useful for generating config file templates, shell completions, or documentation.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.