Trait salak::PropertySource[][src]

pub trait PropertySource: Send + Sync {
    fn name(&self) -> &str;
fn get_property(&self, key: &Key<'_>) -> Option<Property<'_>>;
fn get_sub_keys<'a>(&'a self, key: &Key<'_>, sub_keys: &mut SubKeys<'a>);
fn is_empty(&self) -> bool; fn reload_source(
        &self
    ) -> Result<Option<Box<dyn PropertySource>>, PropertyError> { ... } }
Expand description

A property source defines how to load properties. salak has some predefined sources, user can provide custom source by implementing this trait.

Sources provided by salak.

  • hashmap source
  • std::env source
  • toml source
  • yaml source

Required methods

Get property by key.

Get all subkeys with given key.

Subkeys are keys without dot(‘.’). This method is unstable, and will be simplified by hidding Key and SubKeys.

Check whether the PropertySource is empty. Empty source will be ignored when registering to salak.

Provided methods

Reload source, if nothing changes, then return none.

Implementors