pub struct Config(/* private fields */);Expand description
Kitsune configuration.
Implementations§
Source§impl Config
impl Config
Sourcepub fn mark_defaults_set(&self)
pub fn mark_defaults_set(&self)
Once defaults are set, generate warnings for any values set beyond this list. So that we can identify no-longer-used config parameters.
Sourcepub fn mark_validated(&self) -> bool
pub fn mark_validated(&self) -> bool
Validate this config before using it in runtime. Returns the previous validation state.
Sourcepub fn mark_runtime(&self)
pub fn mark_runtime(&self)
Once we are done setting initial config, generate warnings for any runtime alterations that do not have update callbacks registered. This way we can tell if runtime config changes are being ignored.
Sourcepub fn get_module_config<D: DeserializeOwned>(&self) -> K2Result<D>
pub fn get_module_config<D: DeserializeOwned>(&self) -> K2Result<D>
Get a set of module config values from this config instance.
Sourcepub fn set_module_config<S: Serialize>(&self, config: &S) -> K2Result<()>
pub fn set_module_config<S: Serialize>(&self, config: &S) -> K2Result<()>
Set any number of module config values on this config instance.
This will error if trying to write an entry where a map currently resides or visa-versa.
Sourcepub fn register_entry_update_cb<D: Display>(
&self,
path: &[D],
update_cb: ConfigUpdateCb,
) -> K2Result<()>
pub fn register_entry_update_cb<D: Display>( &self, path: &[D], update_cb: ConfigUpdateCb, ) -> K2Result<()>
Call this in your module constructor once for every parameter for which you would like to receive runtime updates. This will immediately invoke the callback with the current value to ensure this is atomic. (If this is called before default initialization, that initial value will be json Null.)