1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
use crate::Configuration;

/// Settings struct that can be bound by configuration.
pub trait Settings {
  /// Bind values in self from configuration.
  fn bind<C>(&mut self, config: C)
  where
    C: Configuration;

  /// Get a new settings value from configuration.
  fn get<C>(config: C) -> Self
  where
    C: Configuration,
    Self: Default,
  {
    let mut ret = Self::default();
    Self::bind(&mut ret, config);
    ret
  }
}