Trait configure::Configure [−][src]
pub trait Configure: Sized { fn generate() -> Result<Self, DeserializeError>; fn regenerate(&mut self) -> Result<(), DeserializeError> { ... } }
A configuration struct which can be generated from the environment.
This trait is normally derived using the configure_derive
crate.
ⓘThis example is not tested
#[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
fn generate() -> Result<Self, DeserializeError>
Generate this configuration from the ambient environment.
Provided Methods
fn regenerate(&mut self) -> Result<(), DeserializeError>
Regenerate this configuration.