Skip to main content

FeatureLoader

Trait FeatureLoader 

Source
pub trait FeatureLoader {
    // Required method
    fn load_feature<T>(
        &self,
        key: &str,
    ) -> Result<LoadedFeature<T>, ConfigError>
       where T: DeserializeOwned;

    // Provided method
    fn load_optional_section<T>(
        &self,
        key: &str,
    ) -> Result<FeatureState<T>, ConfigError>
       where T: DeserializeOwned { ... }
}
Expand description

Load optional TOML sections with configurable enable/disable precedence.

Unlike Loader, which returns T::default() for absent sections, FeatureLoader distinguishes absent (feature off) from present (feature on) and enforces a three-level precedence chain:

env var  >  enabled = false  >  section presence  >  section absent

Required Methods§

Source

fn load_feature<T>(&self, key: &str) -> Result<LoadedFeature<T>, ConfigError>

Load the section at key with full metadata.

Applies the full precedence chain — env var override, explicit enabled = false, section presence — and records the reason in the returned LoadedFeature::record.

Provided Methods§

Source

fn load_optional_section<T>( &self, key: &str, ) -> Result<FeatureState<T>, ConfigError>

Load the section at key as a FeatureState, without metadata.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§