#![allow(dead_code, clippy::box_collection)] mod utils; use schematic::*; use std::collections::HashMap; #[derive(Config)] struct Config { field: String, } #[derive(ConfigEnum)] enum ConfigEnum { A, B, C, } // VALUES #[derive(Config)] struct Single(String); #[derive(Config)] struct Multiple(String, usize, bool); #[derive(Config)] struct SingleOption(Option); #[derive(Config)] struct MultipleOption(Option, usize, Option); #[derive(Config)] struct SingleBox(Box); #[derive(Config)] struct MultipleBox(Box, usize, Box); #[derive(Config)] struct SingleOptionBox(Option>); #[derive(Config)] struct MultipleOptionBox(Option>, Option, Box); // NESTED #[derive(Config)] struct NestedSingle(#[setting(nested)] Config); #[derive(Config)] struct NestedMultiple(String, #[setting(nested)] Config); #[derive(Config)] struct NestedVec(#[setting(nested)] Vec); #[derive(Config)] struct NestedMap(#[setting(nested)] HashMap); #[derive(Config)] struct NestedComplex( #[setting(nested)] Option>, #[setting(nested)] HashMap>>, ); // DEFAULT #[derive(Config)] struct DefaultSingle(#[setting(default = "abc")] String); #[derive(Config)] struct DefaultMultiple( String, #[setting(default = 123)] usize, #[setting(default = true)] bool, ); // ENV #[derive(Config)] struct EnvMultiple( #[setting(env = "A")] String, usize, #[setting(env = "C", parse_env = env::parse_bool)] bool, ); // MERGE #[derive(Config)] struct MergeVec(#[setting(merge = merge::append_vec)] Vec); #[derive(Config)] struct MergeMapMultiple( #[setting(merge = merge::merge_hashmap)] HashMap, #[setting(merge = merge::discard)] Option>, ); // VALIDATE #[derive(Config)] struct ValidateSingle(#[setting(validate = validate::not_empty)] String); #[derive(Config)] struct ValidateMultiple( #[setting(validate = validate::not_empty)] String, #[setting(validate = validate::in_range(0, 100))] usize, bool, );