#config-file #configuration #file

graze

A zero-boilerplate configuration library

1 unstable release

0.1.0 Nov 24, 2022

#728 in Configuration

MIT license

9KB
110 lines

graze

Rust build status badge Clippy check status badge Rustfmt check status badge

What is graze?

graze is a zero-boilerplate configuration library.

graze itself does not use serde as a dependency, but can easily be used alongside the serde ecosystem.

Functions

  • load_from_path
  • load_or_default
  • load_or_write_default

Examples

Load a configuration using the toml crate

use serde::Deserialize;

#[derive(Deserialize)]
struct Config {
    message: String
}

fn main() {
    let config = graze::load_from_path("Config.toml", |c| toml::from_str(c))
        .expect("Could not load configuration");

    println!("{}", config.message);
}

Dependencies

~0.3–0.8MB
~19K SLoC