pub trait FromConfigKey<T>where
T: FromStr,{
// Required methods
fn from_conf(conf: &XvcConfig) -> T;
fn try_from_conf(conf: &XvcConfig) -> Result<T, Error>;
}
Expand description
A struct implementing this trait can instantiate itself from XvcConfig.
When an option should be parsed and converted to a struct, it implements this trait. The functions are basically identical, and uses XvcConfig::get_val to instantiate. It’s used to bind a configuration key (str) “group.key” with a struct.
See conf macro below for a shortcut.
Required Methods§
Sourcefn from_conf(conf: &XvcConfig) -> T
fn from_conf(conf: &XvcConfig) -> T
Create a value of type T
from configuration.
Supposed to panic! if there is no key, or the value cannot be parsed.
Sourcefn try_from_conf(conf: &XvcConfig) -> Result<T, Error>
fn try_from_conf(conf: &XvcConfig) -> Result<T, Error>
Try to create a type T
from the configuration.
Returns error if there is no key, or the value cannot be parsed.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.