fn init(matches: &ArgMatches) -> Result<WorkerConfig, MeshSimError> {
    //Read the configuration file.
    let mut current_dir = env::current_dir().map_err(|e| {
        let err_msg = String::from("Failed to read current directory");
        MeshSimError {
            kind: MeshSimErrorKind::Configuration(err_msg),
            cause: Some(Box::new(e)),
        }
    })?;
    let config_file_path = matches.value_of(ARG_CONFIG).unwrap_or_else(|| {
        //No configuration file was passed. Look for default option: current_dir + default name.
        current_dir.push(CONFIG_FILE_NAME);
        current_dir
            .to_str()
            .expect("No configuration file was provided and current directory is not readable.")
    });
    let mut configuration = load_conf_file(config_file_path)?;
    //Validate the current configuration
    validate_config(&mut configuration, &matches)?;

    Ok(configuration)
}
/// The init process performs all initialization required for the worker_cli.
/// It performs 2 main tasks: read the configuration file and process the command line parameters.
The init process performs all initialization required for the worker_cli.
It performs 2 main tasks: read the configuration file and process the command line parameters.
The init process performs all initialization required for the worker_cli . It performs 2 main tasks : read the configuration file and process the command line parameters .
fn init(matches: &ArgMatches) -> Result<WorkerConfig, MeshSimError> {
    //Read the configuration file.
    let mut current_dir = env::current_dir().map_err(|e| {
        let err_msg = String::from("Failed to read current directory");
        MeshSimError {
            kind: MeshSimErrorKind::Configuration(err_msg),
            cause: Some(Box::new(e)),
        }
    })?;
    let config_file_path = matches.value_of(ARG_CONFIG).unwrap_or_else(|| {
        //No configuration file was passed. Look for default option: current_dir + default name.
        current_dir.push(CONFIG_FILE_NAME);
        current_dir
            .to_str()
            .expect("No configuration file was provided and current directory is not readable.")
    });
    let mut configuration = load_conf_file(config_file_path)?;
    //Validate the current configuration
    validate_config(&mut configuration, &matches)?;
    Ok(configuration)
}
fn init ( matches : & ArgMatches ) -> Result < WorkerConfig , MeshSimError > { //Read the configuration file. let mut current_dir = env :: current_dir ( ) . map_err ( | e | { let err_msg = String :: from ( " " ) ; MeshSimError { kind : MeshSimErrorKind :: Configuration ( err_msg ) , cause : Some ( Box :: new ( e ) ) , } } ) ? ; let config_file_path = matches . value_of ( ARG_CONFIG ) . unwrap_or_else ( | | { //No configuration file was passed. Look for default option: current_dir + default name. current_dir . push ( CONFIG_FILE_NAME ) ; current_dir . to_str ( ) . expect ( " " ) } ) ; let mut configuration = load_conf_file ( config_file_path ) ? ; //Validate the current configuration validate_config ( & mut configuration , & matches ) ? ; Ok ( configuration ) }
The init process performs all initialization required for the worker_cli.
The init process performs all initialization required for the worker_cli .
matches
&ArgMatches