5 unstable releases

0.14.1 Aug 21, 2021
0.14.0 Jul 27, 2021
0.13.1 Jun 13, 2021
0.6.1 Mar 6, 2021

#106 in Configuration

37 downloads per month
Used in salak_factory

MIT license


salak involve too many stuffs and confused names not only config, please use cfg-rs instead.

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.


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")
let config = env.get::<Config>().unwrap();
assert_eq!(2021, config.value);
assert_eq!(None, config.optional);
assert_eq!(false, config.verbose);

Trait FromEnvironment

Salak Factory

salak_factory can initialize resource based on salak, such as redis, postgresql, etc.

use std::sync::Arc;

use salak::*;
use salak_factory::redis_default::RedisPool;

generate_service!(RedisService {
  redis: RedisPool,
  #[salak(namespace = "hello", access = "pub")]
  back: Option<RedisPool>

fn main() -> Result<(), PropertyError> {
    let env = Salak::builder()
    let _service = env.get_service::<RedisService>()?;
    let _conn = _service.as_redis().get()?;


~35K SLoC

< a