2 unstable releases

new 0.9.0 May 15, 2021
0.7.0 Apr 8, 2021
0.6.1 Mar 6, 2021

#41 in Configuration

Download history 37/week @ 2021-02-10 63/week @ 2021-02-17 32/week @ 2021-02-24 35/week @ 2021-03-03 14/week @ 2021-03-10 3/week @ 2021-03-17 25/week @ 2021-03-24 17/week @ 2021-03-31 31/week @ 2021-04-07 50/week @ 2021-04-14 9/week @ 2021-04-21 35/week @ 2021-04-28 5/week @ 2021-05-05

124 downloads per month
Used in salak_factory

MIT license

61KB
1.5K SLoC

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

use salak::*;

#[derive(Debug, FromEnvironment)]
#[salak(prefix = "config")]
struct Config {
    #[salak(default = false)]
    verbose: bool,
    optional: Option<String>,
    #[salak(name = "val")]
    value: i64,
}
let env = Salak::builder()
    .set("config.val", "2021")
    .unwrap_build();
let config = env.get::<Config>().unwrap();
assert_eq!(2021, config.value);
assert_eq!(None, config.optional);
assert_eq!(false, config.verbose);

Salak Factory

salak_factory is out-of-box crate for using well known components, such as redis, postgresql, etc.

use salak::*;
use salak_factory::{redis_default::RedisConfig, Factory};

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

Dependencies

~360–750KB
~17K SLoC