fn validate_shas<'a, T: Iterator<Item = &'a String>>(
    inv: &crate::Invoice,
    parcels: T,
) -> Result<()> {
    let zero_vec = Vec::with_capacity(0);
    let offending_shas: Vec<String> = parcels
        .filter(|s| {
            !inv.parcel
                .as_ref()
                .unwrap_or(&zero_vec)
                .iter()
                .any(|p| &p.label.sha256 == *s)
        })
        .cloned()
        .collect();
    if !offending_shas.is_empty() {
        Err(ClientError::Other(format!(
            "Got collection of parcels containing parcels that do not exist in the invoice: {}",
            offending_shas.join(", ")
        )))
    } else {
        Ok(())
    }
}
/// Validates all shas in the hashmap to make sure they exist in the invoice. Returns an error
/// containing a list of the offending SHAs that aren't found in the invoice
Validates all shas in the hashmap to make sure they exist in the invoice. Returns an error
containing a list of the offending SHAs that aren't found in the invoice
Validates all shas in the hashmap to make sure they exist in the invoice . Returns an error containing a list of the offending SHAs that aren ' t found in the invoice
fn validate_shas<'a, T: Iterator<Item = &'a String>>(
    inv: &crate::Invoice,
    parcels: T,
) -> Result<()> {
    let zero_vec = Vec::with_capacity(0);
    let offending_shas: Vec<String> = parcels
        .filter(|s| {
            !inv.parcel
                .as_ref()
                .unwrap_or(&zero_vec)
                .iter()
                .any(|p| &p.label.sha256 == *s)
        })
        .cloned()
        .collect();
    if !offending_shas.is_empty() {
        Err(ClientError::Other(format!(
            "Got collection of parcels containing parcels that do not exist in the invoice: {}",
            offending_shas.join(", ")
        )))
    } else {
        Ok(())
    }
}
fn validate_shas < ' a , T : Iterator < Item = & ' a String > > ( inv : & crate :: Invoice , parcels : T , ) -> Result < ( ) > { let zero_vec = Vec :: with_capacity ( 0 ) ; let offending_shas : Vec < String > = parcels . filter ( | s | { ! inv . parcel . as_ref ( ) . unwrap_or ( & zero_vec ) . iter ( ) . any ( | p | & p . label . sha256 == * s ) } ) . cloned ( ) . collect ( ) ; if ! offending_shas . is_empty ( ) { Err ( ClientError :: Other ( format ! ( " " offending_shas join ( " " ) ) ) ) } else { Ok ( ( ) ) } }
Validates all shas in the hashmap to make sure they exist in the invoice.
Validates all shas in the hashmap to make sure they exist in the invoice .
inv
&crate::Invoice
parcels
T
inv
&crate::Invoice
parcels
T