02

Profig

rust

A configuration framework for Rust with schema validation, sample generation, and documentation support.

The Reason

Config management in Rust was traditionally verbose: you define custom structs, parse files with Serde, and manually validate every field. I wanted a tool that makes defining, validating, and documenting config schemas ergonomic without sacrificing performance or type safety — especially for CLI tools, servers, and backend services. Profig was my attempt to explore procedural macros and metadata-driven design in Rust.

What It Does

Profig lets you define configuration schemas using #[derive(Profig)] and enrich fields with metadata like validation rules, defaults, and documentation. It can:

Technical Design

Here's a minimal example of how a config struct is defined:

use profig::Profig;

#[derive(Profig)]
#[profig(format="toml, json")]
struct AppConfig {
    #[profig(min="4", max="10", doc="Number of worker threads")]
    threads: usize,

    #[profig(doc="Path to output directory")]
    output_dir: String,

    #[profig(default="false", doc="Enable debug mode")]
    debug: Option<bool>,
}

Then loading is as simple as:

let config = AppConfig::load("config.toml")?;
println!("Threads: {}", config.threads);

This design leverages Rust's procedural macros to automatically generate parsing, validation, and documentation logic from the struct definition.

Challenges

Usage

Profig is published on crates.io and can be added to your project using:

cargo add profig --features "toml,json,yaml"

Links

Images

Profig-1 Profig-2 Profig-3