Module plugx_config::loader
source · Expand description
Configuration loader trait and implementations.
A configuration loader only loads contents of one or more plugins. No parsing is done here. The result is just a hashmap with keys as plugin names (in lowercase) and ConfigurationEntity as keys. A loader also should try to set contents format for each plugin. For example [fs] (that implements ConfigurationLoader) that loads configurations from filesystem, guesses content formats from file extensions.
Main method of ConfigurationLoader trait is try_load that accepts a URL and maybe a
whitelist of plugin names. It can parse the URL to detect and validate its own options.
For example env that loads configuration from environment-variables
accepts a URL like env://?prefix=MY_APP_NAME and [fs] accepts a URL
like file:///path/to/a/file.json?skippable[0]=notfound (skippable is a list and should
contain error kinds that we want to skip if they happen).
Note that generally you do not need to implement ConfigurationLoader for your own structs and provided closure lets you implement your own loader with just one Fn closure.
Modules
- Custom configuration loader with Fn.
- Environment-Variables configuration loader.
Enums
- Loaded error type.
Traits
- A trait to load configurations for one or more plugins.
Functions
- Checks query-string part of URL and tries to deserialize it to provided type.
Type Aliases
- A modifier Fn that modifies loaded configurations (if needed).