salak

Salak is a multi layered configuration loader and zero-boilerplate configuration parser, with many predefined sources.

Crates.io Crates.io Documentation dependency status License Actions Status

Please refer to salak doc.

Notice

Please notice that salak-0.9.* is totally rewrited, so the APIs may changes much, and some functions may be removed. They will be added in later version.

Quick Example

```rust use salak::*;

[derive(Debug, FromEnvironment)]

[salak(prefix = "config")]

struct Config { #[salak(default = false)] verbose: bool, optional: Option, #[salak(name = "val")] value: i64, } let env = Salak::builder() .set("config.val", "2021") .unwrapbuild(); let config = env.get::().unwrap(); asserteq!(2021, config.value); asserteq!(None, config.optional); asserteq!(false, config.verbose); ```

Salak Factory

salakfactory is out-of-box crate for using well known components, such as redis, postgresql, etc. ```rust use salak::*; use salakfactory::{redis_default::RedisConfig, Factory};

fn main() -> Result<(), PropertyError> { let env = Salak::new()?; let redispool = env.build::()?; let redisconn = redispool.get().unwrap(); let _: u64 = redisconn.set("hello", 1u64).unwrap(); Ok(()) } ```