Trail Config
Simple Rust library to help with reading (and formatting) values from config files.
Currently only supports YAML format (uses serde_yaml library).
Examples
Sample config.yaml file
app:
port: 1000
db:
redis:
server: 127.0.0.1
port: 6379
key_expiry: 3600
sql:
driver: SQL Server
server: 127.0.0.1
database: my_db
username: user
password: Pa$$w0rd!
Default configuration
let config = default; // loads config.yaml file
let port = config.get.unwrap; // returns serde_yaml::value::Value
let port = config.str;
assert_eq!;
let redis = config.get; // returns serde_yaml::value::Value (in this case Mapping)
let redis = config.str;
assert_eq!;
let expiry = config.str;
assert_eq!;
let redis = config.fmt;
assert_eq!;
let conn = config.fmt;
assert_eq!;
With custom separator
let config = new.unwrap;
let port = config.str;
assert_eq!;
With environment variable
let config = new.unwrap; // loads config.dev.yaml
assert_eq!;
License
This project is licensed under the MIT License - see the LICENSE file for details