fn read_report_files(input_dir: &str) -> std::io::Result<Vec<DMARCAggregateReport>> {
    let input_path = Path::new(input_dir);
    let mut all_data: Vec<DMARCAggregateReport> = Vec::new();

    if input_path.is_dir() {
        for dir_entry in fs::read_dir(input_path)? {
            let dir_entry = dir_entry?;
            if !dir_entry.path().is_dir() {
                debug!("Reading file: {:?}", dir_entry.file_name());
                let mut contents = String::new();
                let mut file = File::open(dir_entry.path())?;
                file.read_to_string(&mut contents)?;

                let report = parse_report_xml(contents).unwrap();

                trace!(
                    "Made a struct and it is for org {:?}",
                    report.report_metadata.org_name
                );

                all_data.push(report);
            }
        }
    }

    Ok(all_data)
}
/**
 * Read in each file one at a time and load as a DMARCAggregateReport, then process them all.
 */
Read in each file one at a time and load as a DMARCAggregateReport, then process them all.
Read in each file one at a time and load as a DMARCAggregateReport then process them all .
fn read_report_files(input_dir: &str) -> std::io::Result<Vec<DMARCAggregateReport>> {
    let input_path = Path::new(input_dir);
    let mut all_data: Vec<DMARCAggregateReport> = Vec::new();
    if input_path.is_dir() {
        for dir_entry in fs::read_dir(input_path)? {
            let dir_entry = dir_entry?;
            if !dir_entry.path().is_dir() {
                debug!("Reading file: {:?}", dir_entry.file_name());
                let mut contents = String::new();
                let mut file = File::open(dir_entry.path())?;
                file.read_to_string(&mut contents)?;
                let report = parse_report_xml(contents).unwrap();
                trace!(
                    "Made a struct and it is for org {:?}",
                    report.report_metadata.org_name
                );
                all_data.push(report);
            }
        }
    }
    Ok(all_data)
}
fn read_report_files ( input_dir : & str ) -> std :: io :: Result < Vec < DMARCAggregateReport > > { let input_path = Path :: new ( input_dir ) ; let mut all_data : Vec < DMARCAggregateReport > = Vec :: new ( ) ; if input_path . is_dir ( ) { for dir_entry in fs :: read_dir ( input_path ) ? { let dir_entry = dir_entry ? ; if ! dir_entry . path ( ) . is_dir ( ) { debug ! ( " " dir_entry file_name ( ) ) ; let mut contents = String :: new ( ) ; let mut file = File :: open ( dir_entry . path ( ) ) ? ; file . read_to_string ( & mut contents ) ? ; let report = parse_report_xml ( contents ) . unwrap ( ) ; trace ! ( " " report report_metadata org_name ) ; all_data . push ( report ) ; } } } Ok ( all_data ) }
Read in each file one at a time and load as a DMARCAggregateReport, then process them all.
Read in each file one at a time and load as a DMARCAggregateReport then process them all .
input_dir
&str