Skip to main content

ConfigBuilder

Trait ConfigBuilder 

Source
pub trait ConfigBuilder: Sized {
    // Required methods
    fn name(&self) -> &str;
    fn version(&self) -> &str;
    fn with_name(self, name: impl Into<String>) -> Self;
    fn with_version(self, version: impl Into<String>) -> Self;
    fn with_config_dir(self, dir: impl Into<PathBuf>) -> Self;
    fn with_config_filename(self, filename: impl Into<String>) -> Self;
}
Expand description

Assemble application configuration from named sources.

ConfigBuilder is a builder-chain trait – it covers only the configuration fields (name, version, with_config_dir, with_config_filename). It deliberately does not include build_loader(). That finaliser is an inherent method on the concrete builder types (see configbuilder-svc-saf) because the construction logic depends on real filesystem/XDG internals this trait itself must not reference.

Required Methods§

Source

fn name(&self) -> &str

Return the configured application name.

Source

fn version(&self) -> &str

Return the configured application version.

Source

fn with_name(self, name: impl Into<String>) -> Self

Set the application name; used by build_loader to resolve XDG paths.

Source

fn with_version(self, version: impl Into<String>) -> Self

Set the application version string.

Source

fn with_config_dir(self, dir: impl Into<PathBuf>) -> Self

Append an explicit config directory; takes precedence over XDG resolution.

Multiple calls accumulate directories – later entries win on key conflicts.

Source

fn with_config_filename(self, filename: impl Into<String>) -> Self

Override the config filename searched for in each configured directory.

Defaults to application.toml when not called.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§