pub struct ConfigLoader<E> { /* private fields */ }
Expand description
An instance which holds the loader instance.
Implementations§
Source§impl ConfigLoader<()>
A default realization.
impl ConfigLoader<()>
A default realization.
Sourcepub fn new<E>(source: Box<dyn ConfigLoaderSource>, stor: E) -> ConfigLoader<E>
pub fn new<E>(source: Box<dyn ConfigLoaderSource>, stor: E) -> ConfigLoader<E>
Creates new instance.
§Arguments
-
source
- a dynamic ConfigLoaderSource instance which performs loading. -
stor
- a generic which can be used as a special storage.
§Returns
An instance of the ConfigLoader is returned.
Source§impl<E> ConfigLoader<E>
impl<E> ConfigLoader<E>
Sourcepub fn load_file<D, P>(
&self,
env_ser: &str,
filepath: P,
) -> Result<ConfigLoaded<D>, String>
pub fn load_file<D, P>( &self, env_ser: &str, filepath: P, ) -> Result<ConfigLoaded<D>, String>
Loads a file by the provided path and parses it.
§Arguments
-
env_ser
- A serializator name of the scheme serializator. If loaded from non local loaders this value may be ignored by the inner loader. -
filepath
- A path to the file. Depending on the inner loader realization, the path is partial i.e from the basepath of your config files. For example: the config files are physically located at/etc/myprogram
, so the path to the server.shm will be/server.shm
.
A Result is returned with the:
-
[Result::Ok()] is returned with inner type ConfigLoaded which contains a deserialized structure or enumerator, source and path.
-
[Result::Err()] is returned with the error description.
Sourcepub fn read_raw_file<P>(&self, filepath: P) -> Result<String, String>
pub fn read_raw_file<P>(&self, filepath: P) -> Result<String, String>
Just reads the file and returns its content back as UTF-8 [Stirng]. This can be used for
non config files. However for small one. For a large which content is large and will
less likly fit in the RAM, use read_raw_file_buffered
.