konfik_derive
Derive macro for the konfik configuration parsing library.
Overview
This crate provides the #[derive(Config)] procedural macro that automatically implements the necessary traits for structs to work with the konfik configuration loader.
Usage
Add to your Cargo.toml:
[]
= "0.1" # This includes the derive macro
= { = "1.0", = ["derive"] }
Use the derive macro on your configuration struct:
use Config; // Re-exported from konfik
use Deserialize;
The macro automatically implements:
konfik::config_meta::ConfigMetadata- Provides metadata about configuration fieldskonfik::LoadConfig- Enables loading configuration from various sources
Requirements
- The struct must have named fields (tuple structs and unit structs are not supported)
- The struct must implement
serde::Deserialize - All fields must be compatible with serde serialization/deserialization
Generated Code
The derive macro generates implementations that allow the struct to:
- Be loaded using
ConfigLoader::load::<YourStruct>() - Use the convenient
YourStruct::load()method - Provide field metadata for environment variable and CLI argument mapping
License
This project is licensed under the MIT License - see the LICENSE file for details.