let start_firmware_update = |file_name: &str| -> () { match hid_device_manager.connect_to_bootstrap_loader_mode_compatible_device() { Ok(updatable_device) => { match updatable_device.start_first_part() { Ok(_) => { match hid_device_manager.connect_to_bootstrap_loader_mode_compatible_device() { Ok(updatable_device_next) => { match updatable_device_next.start_second_part(Path::new(file_name)) { Ok(_) => { println!("Firmware has been updated !"); }, Err(reason) => println!("{}", Red.paint(format!("Unable to update the firmware. Reason: {}", reason))) } }, Err(_) => println!("{}", Red.paint("Unable to connect to the Bootstrap Loader mode compatible device. Make sure the USB cable is properly plugged in.")) } }, Err(reason) => println!("{}", Red.paint(format!("Unable to update the firmware. Reason: {}", reason))) } }, Err(_) => println!("{}", Red.paint("Unable to connect to the Bootstrap Loader mode compatible device. Make sure the USB cable is properly plugged in.")) } };