pub trait ConfigLoaderSource {
// Required methods
fn get_serializator(
&self,
serial_name: &str,
) -> Result<Arc<DynEnvironment>, String>;
fn is_local(&self) -> bool;
fn read_file(
&self,
path: &Path,
dynenv_name: &str,
) -> Result<String, String>;
fn read_raw_file(&self, path: &Path) -> Result<String, String>;
}
Expand description
A trait which is implemented by the user’s loader instance.
Required Methods§
Sourcefn get_serializator(
&self,
serial_name: &str,
) -> Result<Arc<DynEnvironment>, String>
fn get_serializator( &self, serial_name: &str, ) -> Result<Arc<DynEnvironment>, String>
Returns the cloned dynamic serializator instance.
Sourcefn read_file(&self, path: &Path, dynenv_name: &str) -> Result<String, String>
fn read_file(&self, path: &Path, dynenv_name: &str) -> Result<String, String>
Reads file located on the path
and attempts to use the serializator title to
load the config file.
§Arguments
-
path
- a path to the file’s location. -
dynenv_name
- a serializator instance name. If reading from remote source, then this is not needed as usually there is stored already serialized data from configs. Normally, the path is partial. It means that the realization behind this trait must add the root path to the configutation dir or prepare the instance in a way so for the caller, the path is generic for any type of loader.
For example: file located virtually at /servers/myserver1.shm
is resolved by local
loader as /etc/myprogram/servers/myserver1.shm
and by remote /cnoderoot/servers/myserver1.shm
.
§Return
A Result is returned.
-
Result::Ok with the content in String
-
Result::Err with the error descriptioon as String
Sourcefn read_raw_file(&self, path: &Path) -> Result<String, String>
fn read_raw_file(&self, path: &Path) -> Result<String, String>
Reads a content of the file without performing any deserialization or parsing.
§Arguments
path
- a path to the file’s location.
§Return
A Result is returned.
-
Result::Ok with the content in String
-
Result::Err with the error descriptioon as String