configurator 0.1.0

Statically-Typed Configuration Structs / Files for Rust.
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 0 items with examples
  • Size
  • Source code size: 4.44 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.05 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Innectic

Configurator

Configurator makes statically-typed configuration for Rust easy.

Example

main.rs:

#[macro_use]
extern crate serde_derive;
extern crate serde_json;

#[macro_use]
extern crate configurator;

use std::fs::File;
use std::io::prelude::*;

#[derive(Debug, Deserialize)]
struct Testing {
	a: String
}

fn main() {
	match load_config!(Testing, "config.json") {
		Ok(c) => println!("{:?}", c),
		Err(e) => println!("Encountered an error: {}", e)
	}
}

config.json:

{
	"a": "Testing all the things"
}

Result:

Testing { a: "Testing all the things" }

Unfortunately, we currently rely on serde for JSON-to-file conversions.