Trait abscissa::GlobalConfig [−][src]
pub trait GlobalConfig: 'static + Clone + DeserializeOwned { fn get_global() -> ConfigReader<Self>; fn set_global(config: Self); fn load_toml<T: AsRef<str>>(toml_string: T) -> Result<Self, FrameworkError> { ... } fn load_toml_file<P>(path: &P) -> Result<Self, FrameworkError>
where
P: AsRef<CanonicalPath>, { ... } fn set_from_toml_file<P>(
path: &P
) -> Result<ConfigReader<Self>, FrameworkError>
where
P: AsRef<CanonicalPath>, { ... } fn set_from_toml_file_or_exit<P>(path: &P) -> ConfigReader<Self>
where
P: AsRef<CanonicalPath>, { ... } fn not_loaded() -> ! { ... } }
Common functions for loading and reading application configuration from
TOML files (providing a global lock which allows many readers, and can be
automatically implemented using the impl_global_config!
macro.
Required Methods
fn get_global() -> ConfigReader<Self>
Get the global configuration, acquiring a lock around it. If the
configuration hasn't been loaded, calls Self::not_loaded()
.
fn set_global(config: Self)
Set the global configuration to the given value
Provided Methods
fn load_toml<T: AsRef<str>>(toml_string: T) -> Result<Self, FrameworkError>
Load the configuration from the given TOML string
fn load_toml_file<P>(path: &P) -> Result<Self, FrameworkError> where
P: AsRef<CanonicalPath>,
P: AsRef<CanonicalPath>,
Load the global configuration from the TOML file at the given path. If an error occurs reading or parsing the file, print it out and exit.
fn set_from_toml_file<P>(path: &P) -> Result<ConfigReader<Self>, FrameworkError> where
P: AsRef<CanonicalPath>,
P: AsRef<CanonicalPath>,
Parse the given TOML file and set the global configuration to the result
fn set_from_toml_file_or_exit<P>(path: &P) -> ConfigReader<Self> where
P: AsRef<CanonicalPath>,
P: AsRef<CanonicalPath>,
Load the given TOML configuration file, printing an error message and exiting if it's invalid
fn not_loaded() -> !
Error handler called if Self::get()
is invoked before the global
configuration has been loaded. This indicates a bug in the program
accessing this type.