configbuilder-pattern-builder 0.1.0

configbuilder-pattern: builder domain (ConfigBuilder/BuilderFinalizer), trait contract + tech-agnostic reference implementation.
Documentation
//! Canonical usage of the `ConfigBuilder` trait's fluent setters.
//!
//! This crate defines the contract only -- `configbuilder-svc-saf`'s
//! `TomlConfigBuilder` is the real, filesystem-backed implementor. This example
//! shows the trait shape against a minimal local implementor.

use configbuilder_pattern_builder::ConfigBuilder;

struct DemoBuilder {
    name: String,
    version: String,
}

impl ConfigBuilder for DemoBuilder {
    fn name(&self) -> &str {
        &self.name
    }

    fn version(&self) -> &str {
        &self.version
    }

    fn with_name(mut self, name: impl Into<String>) -> Self {
        self.name = name.into();
        self
    }

    fn with_version(mut self, version: impl Into<String>) -> Self {
        self.version = version.into();
        self
    }

    fn with_config_dir(self, _dir: impl Into<std::path::PathBuf>) -> Self {
        self
    }

    fn with_config_filename(self, _filename: impl Into<String>) -> Self {
        self
    }
}

fn main() {
    let builder = DemoBuilder {
        name: String::new(),
        version: String::new(),
    }
    .with_name("example-app")
    .with_version("1.0.0");

    println!("{} v{}", builder.name(), builder.version());
}