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
PropertySource name.
fn get_property(&self, key: &Key<'_>) -> Option<Property<'_>>[src]
fn get_property(&self, key: &Key<'_>) -> Option<Property<'_>>[src]Get property by key.
fn get_sub_keys<'a>(&'a self, key: &Key<'_>, sub_keys: &mut SubKeys<'a>)[src]
fn get_sub_keys<'a>(&'a self, key: &Key<'_>, sub_keys: &mut SubKeys<'a>)[src]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
fn reload_source(
&self
) -> Result<Option<Box<dyn PropertySource>>, PropertyError>[src]
fn reload_source(
&self
) -> Result<Option<Box<dyn PropertySource>>, PropertyError>[src]Reload source, if nothing changes, then return none.