pub fn from_file(custom_path: Option<PathBuf>) -> Result<Config, ConfigError> {
        let config_file = custom_path.unwrap_or(config_file_path()?);

        let config = std::fs::read(&config_file)
            .map_err(|e| ConfigError(format!("Reading configuration file: {}", e)))
            .and_then(|file_content| {
                toml::from_slice::<Config>(&file_content)
                    .map_err(|e| ConfigError(format!("Parsing configuration file: {}", e)))
            })?;

        // FIXME: this check is removed as we're not using watchtowers at the moment,
        // and having the user to insert some dummy keys is awkward.
        // let stk_len = config.stakeholders.len();
        // let wt_len = config.watchtowers.len();
        // if stk_len > wt_len {
        //     return Err(ConfigError(format!(
        //         "Not enough watchtowers ({} stakeholders, but only {} watchtowers)",
        //         stk_len, wt_len
        //     )));
        // }

        Ok(config)
    }
/// Get our static configuration out of a mandatory configuration file.
///
/// We require all settings to be set in the configuration file, and only in the configuration
/// file. We don't allow to set them via the command line or environment variables to avoid a
/// futile duplication.
Get our static configuration out of a mandatory configuration file.
We require all settings to be set in the configuration file, and only in the configuration
file. We don't allow to set them via the command line or environment variables to avoid a
futile duplication.
Get our static configuration out of a mandatory configuration file . We require all settings to be set in the configuration file and only in the configuration file . We don ' t allow to set them via the command line or environment variables to avoid a futile duplication .
pub fn from_file(custom_path: Option<PathBuf>) -> Result<Config, ConfigError> {
        let config_file = custom_path.unwrap_or(config_file_path()?);
        let config = std::fs::read(&config_file)
            .map_err(|e| ConfigError(format!("Reading configuration file: {}", e)))
            .and_then(|file_content| {
                toml::from_slice::<Config>(&file_content)
                    .map_err(|e| ConfigError(format!("Parsing configuration file: {}", e)))
            })?;
        // FIXME: this check is removed as we're not using watchtowers at the moment,
        // and having the user to insert some dummy keys is awkward.
        // let stk_len = config.stakeholders.len();
        // let wt_len = config.watchtowers.len();
        // if stk_len > wt_len {
        //     return Err(ConfigError(format!(
        //         "Not enough watchtowers ({} stakeholders, but only {} watchtowers)",
        //         stk_len, wt_len
        //     )));
        // }
        Ok(config)
    }
pub fn from_file ( custom_path : Option < PathBuf > ) -> Result < Config , ConfigError > { let config_file = custom_path . unwrap_or ( config_file_path ( ) ? ) ; let config = std :: fs :: read ( & config_file ) . map_err ( | e | ConfigError ( format ! ( " " e ) ) ) . and_then ( | file_content | { toml :: from_slice :: < Config > ( & file_content ) . map_err ( | e | ConfigError ( format ! ( " " e ) ) ) } ) ? ; // FIXME: this check is removed as we're not using watchtowers at the moment, // and having the user to insert some dummy keys is awkward. // let stk_len = config.stakeholders.len(); // let wt_len = config.watchtowers.len(); // if stk_len > wt_len { //     return Err(ConfigError(format!( //         "Not enough watchtowers ({} stakeholders, but only {} watchtowers)", //         stk_len, wt_len //     ))); // } Ok ( config ) }
Get our static configuration out of a mandatory configuration file.
Get our static configuration out of a mandatory configuration file .
custom_path
Option<PathBuf>
custom_path
Option<PathBuf>