Trait configure::Configure

source ·
pub trait Configure: Sized {
    // Required method
    fn generate() -> Result<Self, DeserializeError>;

    // Provided method
    fn regenerate(&mut self) -> Result<(), DeserializeError> { ... }
}
Expand description

A configuration struct which can be generated from the environment.

This trait is normally derived using the configure_derive crate.

#[derive(Configure)]
pub struct Config {
    /// This can be set through the LIBNAME_HOST variable
    pub host: SocketAddr,
    /// This can be set through the LIBNAME_THREADS variable
    pub threads: usize,
}

// To generate your configuration from the environment:
let cfg = Config::generate()?;

Required Methods§

source

fn generate() -> Result<Self, DeserializeError>

Generate this configuration from the ambient environment.

Provided Methods§

source

fn regenerate(&mut self) -> Result<(), DeserializeError>

Regenerate this configuration.

Object Safety§

This trait is not object safe.

Implementors§