Crate configure [] [src]

Configuration management.

This crate is intended to automatically bridge the gap from envionmental configuration into your project. By deriving the Configure trait for your configuration, you can get an automatic system for managing your configuration at runtime.

Deriving Configure

This library provides a custom derive which lets you derive the Configure trait. It requires that your type implement Deserialize.

We recommend that you implement configuration using these steps:

  1. Implement Default for your type, which provides the default values for each configuration field.
  2. Derive both Deserialize and Configure for your type. Use the #[serde(default)] attribute to fall back to the default implementation when the configurable values are not set.

For example:

Be careful when using this code, it's not being tested!
extern crate configure;
extern crate serde;
extern crate serde_derive;

use std::net::SocketAddr;
use std::path::PathBuf;

#[derive(Deserialize, Configure)]
pub struct Config {
    addr: SocketAddr,
    tls_cert: Option<PathBuf>,

impl Default for Config {
    fn default() -> Config {
        Config {
            addr: "".parse().unwrap(),
            tls_cert: None,

With this code, you can call Config::generate to pull you configuration from the environment, falling back to these default values if the end user has not set custom configuration for it.



Controlling the source of configuration.





Error when a Serializer or Deserializer trait object fails.



A configuration struct which can be generated from the environment.