pub fn initialize_target_data(
    tss: &Vec<Mutex<TargetStackShield>>,
    data: HiveTargetData,
) -> Result<(), InitError> {
    // Check for data desync
    let detected_daughterboards = detect_connected_daughterboards(tss);
    if data
        .iter()
        .enumerate()
        .filter(|(idx, data)| {
            if data.is_some() == detected_daughterboards[*idx] {
                return false;
            }
            true
        })
        .count()
        != 0
    {
        log::error!("Encountered data desync during target data initialization.\nData received:\n{:#?}\nDaughterboards detected by the application:\n{:#?}", data, detected_daughterboards);
        return Err(InitError::TargetInitDesync);
    }

    for (idx, targets) in data.into_iter().enumerate().filter_map(|(idx, data)| {
        if data.is_some() {
            return Some((idx, data.unwrap()));
        }
        None
    }) {
        let mut tss = tss[idx].lock().unwrap();
        tss.set_targets(targets);
    }

    Ok(())
}
/// Initializes TSS with target data and checks for data desyncs between the currently detected hardware and the provided data
Initializes TSS with target data and checks for data desyncs between the currently detected hardware and the provided data
Initializes TSS with target data and checks for data desyncs between the currently detected hardware and the provided data
pub fn initialize_target_data(
    tss: &Vec<Mutex<TargetStackShield>>,
    data: HiveTargetData,
) -> Result<(), InitError> {
    // Check for data desync
    let detected_daughterboards = detect_connected_daughterboards(tss);
    if data
        .iter()
        .enumerate()
        .filter(|(idx, data)| {
            if data.is_some() == detected_daughterboards[*idx] {
                return false;
            }
            true
        })
        .count()
        != 0
    {
        log::error!("Encountered data desync during target data initialization.\nData received:\n{:#?}\nDaughterboards detected by the application:\n{:#?}", data, detected_daughterboards);
        return Err(InitError::TargetInitDesync);
    }
    for (idx, targets) in data.into_iter().enumerate().filter_map(|(idx, data)| {
        if data.is_some() {
            return Some((idx, data.unwrap()));
        }
        None
    }) {
        let mut tss = tss[idx].lock().unwrap();
        tss.set_targets(targets);
    }
    Ok(())
}
pub fn initialize_target_data ( tss : & Vec < Mutex < TargetStackShield > > , data : HiveTargetData , ) -> Result < ( ) , InitError > { // Check for data desync let detected_daughterboards = detect_connected_daughterboards ( tss ) ; if data . iter ( ) . enumerate ( ) . filter ( | ( idx , data ) | { if data . is_some ( ) == detected_daughterboards [ * idx ] { return false ; } true } ) . count ( ) != 0 { log :: error ! ( " \n \n \n \n " data detected_daughterboards ) ; return Err ( InitError :: TargetInitDesync ) ; } for ( idx , targets ) in data . into_iter ( ) . enumerate ( ) . filter_map ( | ( idx , data ) | { if data . is_some ( ) { return Some ( ( idx , data . unwrap ( ) ) ) ; } None } ) { let mut tss = tss [ idx ] . lock ( ) . unwrap ( ) ; tss . set_targets ( targets ) ; } Ok ( ( ) ) }
Initializes TSS with target data and checks for data desyncs between the currently detected hardware and the provided data
Initializes TSS with target data and checks for data desyncs between the currently detected hardware and the provided data
tss
&Vec<Mutex<TargetStackShield>>
data
HiveTargetData