Skip to main content

ConfigSchema

Trait ConfigSchema 

Source
pub trait ConfigSchema: Config + Sized {
    // Required method
    fn include_paths(layer: &<Self as Config>::Layer) -> Vec<PathBuf>;

    // Provided method
    fn template_path_for_section(section_path: &[&str]) -> Option<PathBuf> { ... }
}
Expand description

A confique schema that can expose recursive include paths and template section layout.

Implement this trait for the same type that derives confique::Config. include_paths receives a partially loaded layer so the crate can discover child config files before the final schema is merged.

Required Methods§

Source

fn include_paths(layer: &<Self as Config>::Layer) -> Vec<PathBuf>

Returns include paths declared by a loaded config layer.

Relative paths are resolved from the file that declared them. Empty paths are rejected before traversal continues.

§Arguments
  • layer: Partially loaded confique layer for one config file.
§Returns

Returns include paths declared by layer.

Provided Methods§

Source

fn template_path_for_section(section_path: &[&str]) -> Option<PathBuf>

Overrides the generated template file path for a nested section.

By default, top-level sections are generated as config/<field>.yaml and nested sections as children of their parent section file stem, e.g. config/trading/risk.yaml.

§Arguments
  • section_path: Path of nested schema field names from the root schema to the section being rendered.
§Returns

Returns Some(path) to override the generated file path, or None to use the default section path.

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.

Implementors§