pub fn write_hash_comparison_results<Wo: Write, We: Write>(
    output: &mut Wo,
    error: &mut We,
    results: Result<(Vec<CompareResult>, Vec<CompareFileResult>), CompareError>,
) -> Error {
    let result = match results {
        Ok((mut compare_results, mut file_compare_results)) => {
            compare_results.sort();
            file_compare_results.sort();

            for res in &compare_results {
                match *res {
                    CompareResult::FileAdded(ref file) => write_compare_result(output, "File added: ", file),
                    CompareResult::FileRemoved(ref file) => write_compare_result(output, "File removed: ", file),
                    CompareResult::FileIgnored(ref file) => write_compare_result(output, "File ignored, skipping: ", file),
                }
            }

            if file_compare_results.is_empty() && compare_results.is_empty() {
                writeln!(output, "No files left to verify").unwrap();
                Error::NoError
            } else if file_compare_results.is_empty() {
                writeln!(output, "No files to verify").unwrap();
                Error::NoError
            } else {
                if !compare_results.is_empty() {
                    writeln!(output, "").unwrap();
                }

                let mut differed_n = 0;
                for fres in &file_compare_results {
                    match *fres {
                        CompareFileResult::FileMatches { ref file, ref hash } => write_file_result_match(output, file, hash),
                        CompareFileResult::FileDiffers {
                            ref file,
                            ref was_hash,
                            ref new_hash,
                        } => {
                            write_file_result_diff(output, file, was_hash, new_hash);
                            differed_n += 1;
                        }
                    }
                }

                match differed_n {
                    0 => Error::NoError,
                    n => Error::NFilesDiffer(n),
                }
            }
        }
        Err(CompareError::HashLengthDiffers { previous_len, current_len }) => {
            writeln!(error, "Hash lengths do not match; selected: {}, loaded: {}", current_len, previous_len).unwrap();

            Error::HashLengthDiffers
        }
        Err(CompareError::DifferentNumberOfFiles { previous_len, current_len }) => {
            writeln!(error, "File count do not match; selected: {}, loaded: {}", current_len, previous_len).unwrap();

            Error::DifferentNumberOfFiles
        }
    };

    output.flush().unwrap();
    error.flush().unwrap();

    result
}
/// Write hash comparison results to the output streams in a human-consumable format
Write hash comparison results to the output streams in a human-consumable format
Write hash comparison results to the output streams in a human - consumable format
pub fn write_hash_comparison_results<Wo: Write, We: Write>(
    output: &mut Wo,
    error: &mut We,
    results: Result<(Vec<CompareResult>, Vec<CompareFileResult>), CompareError>,
) -> Error {
    let result = match results {
        Ok((mut compare_results, mut file_compare_results)) => {
            compare_results.sort();
            file_compare_results.sort();
            for res in &compare_results {
                match *res {
                    CompareResult::FileAdded(ref file) => write_compare_result(output, "File added: ", file),
                    CompareResult::FileRemoved(ref file) => write_compare_result(output, "File removed: ", file),
                    CompareResult::FileIgnored(ref file) => write_compare_result(output, "File ignored, skipping: ", file),
                }
            }
            if file_compare_results.is_empty() && compare_results.is_empty() {
                writeln!(output, "No files left to verify").unwrap();
                Error::NoError
            } else if file_compare_results.is_empty() {
                writeln!(output, "No files to verify").unwrap();
                Error::NoError
            } else {
                if !compare_results.is_empty() {
                    writeln!(output, "").unwrap();
                }
                let mut differed_n = 0;
                for fres in &file_compare_results {
                    match *fres {
                        CompareFileResult::FileMatches { ref file, ref hash } => write_file_result_match(output, file, hash),
                        CompareFileResult::FileDiffers {
                            ref file,
                            ref was_hash,
                            ref new_hash,
                        } => {
                            write_file_result_diff(output, file, was_hash, new_hash);
                            differed_n += 1;
                        }
                    }
                }
                match differed_n {
                    0 => Error::NoError,
                    n => Error::NFilesDiffer(n),
                }
            }
        }
        Err(CompareError::HashLengthDiffers { previous_len, current_len }) => {
            writeln!(error, "Hash lengths do not match; selected: {}, loaded: {}", current_len, previous_len).unwrap();
            Error::HashLengthDiffers
        }
        Err(CompareError::DifferentNumberOfFiles { previous_len, current_len }) => {
            writeln!(error, "File count do not match; selected: {}, loaded: {}", current_len, previous_len).unwrap();
            Error::DifferentNumberOfFiles
        }
    };
    output.flush().unwrap();
    error.flush().unwrap();
    result
}
pub fn write_hash_comparison_results < Wo : Write , We : Write > ( output : & mut Wo , error : & mut We , results : Result < ( Vec < CompareResult > , Vec < CompareFileResult > ) , CompareError > , ) -> Error { let result = match results { Ok ( ( mut compare_results , mut file_compare_results ) ) => { compare_results . sort ( ) ; file_compare_results . sort ( ) ; for res in & compare_results { match * res { CompareResult :: FileAdded ( ref file ) => write_compare_result ( output , " " , file ) , CompareResult :: FileRemoved ( ref file ) => write_compare_result ( output , " " , file ) , CompareResult :: FileIgnored ( ref file ) => write_compare_result ( output , " " , file ) , } } if file_compare_results . is_empty ( ) && compare_results . is_empty ( ) { writeln ! ( output " " ) . unwrap ( ) ; Error :: NoError } else if file_compare_results . is_empty ( ) { writeln ! ( output " " ) . unwrap ( ) ; Error :: NoError } else { if ! compare_results . is_empty ( ) { writeln ! ( output " " ) . unwrap ( ) ; } let mut differed_n = 0 ; for fres in & file_compare_results { match * fres { CompareFileResult :: FileMatches { ref file , ref hash } => write_file_result_match ( output , file , hash ) , CompareFileResult :: FileDiffers { ref file , ref was_hash , ref new_hash , } => { write_file_result_diff ( output , file , was_hash , new_hash ) ; differed_n += 1 ; } } } match differed_n { 0 => Error :: NoError , n => Error :: NFilesDiffer ( n ) , } } } Err ( CompareError :: HashLengthDiffers { previous_len , current_len } ) => { writeln ! ( error " " current_len previous_len ) . unwrap ( ) ; Error :: HashLengthDiffers } Err ( CompareError :: DifferentNumberOfFiles { previous_len , current_len } ) => { writeln ! ( error " " current_len previous_len ) . unwrap ( ) ; Error :: DifferentNumberOfFiles } } ; output . flush ( ) . unwrap ( ) ; error . flush ( ) . unwrap ( ) ; result }
Write hash comparison results to the output streams in a human-consumable format
Write hash comparison results to the output streams in a human - consumable format
output
&mut Wo
error
&mut We
results
Result<(Vec<CompareResult>, Vec<CompareFileResult>), CompareError>