pub fn load_from_path(path: impl AsRef<Path>) -> Result<Self, ConsensusServiceError> {
        let path = path.as_ref();

        // Read configuration file.
        let data = fs::read_to_string(path).map_err(|err| {
            ConsensusServiceError::Configuration(format!("error reading file: {}", err.to_string()))
        })?;

        // Parse configuration file.
        let tokens_config: Self = match path.extension().and_then(|ext| ext.to_str()) {
            None => Err(ConsensusServiceError::Configuration(
                "failed figuring out file extension".to_owned(),
            )),
            Some("toml") => toml::from_str(&data).map_err(|err| {
                ConsensusServiceError::Configuration(format!("TOML parsing: {:?}", err))
            }),
            Some("json") => serde_json::from_str(&data).map_err(|err| {
                ConsensusServiceError::Configuration(format!("JSON parsing: {:?}", err))
            }),
            Some(ext) => Err(ConsensusServiceError::Configuration(format!(
                "Unrecognized extension '{}'",
                ext
            ))),
        }?;

        tokens_config.validate()?;
        Ok(tokens_config)
    }
/// Get the tokens configuration by loading the tokens.toml/json file.
Get the tokens configuration by loading the tokens.toml/json file.
Get the tokens configuration by loading the tokens . toml / json file .
pub fn load_from_path(path: impl AsRef<Path>) -> Result<Self, ConsensusServiceError> {
        let path = path.as_ref();
        // Read configuration file.
        let data = fs::read_to_string(path).map_err(|err| {
            ConsensusServiceError::Configuration(format!("error reading file: {}", err.to_string()))
        })?;
        // Parse configuration file.
        let tokens_config: Self = match path.extension().and_then(|ext| ext.to_str()) {
            None => Err(ConsensusServiceError::Configuration(
                "failed figuring out file extension".to_owned(),
            )),
            Some("toml") => toml::from_str(&data).map_err(|err| {
                ConsensusServiceError::Configuration(format!("TOML parsing: {:?}", err))
            }),
            Some("json") => serde_json::from_str(&data).map_err(|err| {
                ConsensusServiceError::Configuration(format!("JSON parsing: {:?}", err))
            }),
            Some(ext) => Err(ConsensusServiceError::Configuration(format!(
                "Unrecognized extension '{}'",
                ext
            ))),
        }?;
        tokens_config.validate()?;
        Ok(tokens_config)
    }
pub fn load_from_path ( path : impl AsRef < Path > ) -> Result < Self , ConsensusServiceError > { let path = path . as_ref ( ) ; // Read configuration file. let data = fs :: read_to_string ( path ) . map_err ( | err | { ConsensusServiceError :: Configuration ( format ! ( " " err to_string ( ) ) ) } ) ? ; // Parse configuration file. let tokens_config : Self = match path . extension ( ) . and_then ( | ext | ext . to_str ( ) ) { None => Err ( ConsensusServiceError :: Configuration ( " " . to_owned ( ) , ) ) , Some ( " " ) => toml :: from_str ( & data ) . map_err ( | err | { ConsensusServiceError :: Configuration ( format ! ( " " err ) ) } ) , Some ( " " ) => serde_json :: from_str ( & data ) . map_err ( | err | { ConsensusServiceError :: Configuration ( format ! ( " " err ) ) } ) , Some ( ext ) => Err ( ConsensusServiceError :: Configuration ( format ! ( " " ext ) ) ) , } ? ; tokens_config . validate ( ) ? ; Ok ( tokens_config ) }
Get the tokens configuration by loading the tokens.toml/json file.
Get the tokens configuration by loading the tokens . toml / json file .
path
impl AsRef<Path>