From 2523cc850322faa4fbc3682312ed43d2f56a304a Mon Sep 17 00:00:00 2001 From: gnxlxnxx Date: Sat, 26 Feb 2022 13:37:49 +0100 Subject: [PATCH] use `download_from_slice` function this closes #4 --- src/utils.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index 4655032..6fe9226 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -64,17 +64,7 @@ pub fn flash_bin(binary: &[u8], d: &rusb::Device) -> Result<(), U ) .map_err(|e| UtilError::Dfu(e))?; - std::fs::write("target/out.bin", binary).map_err(|e| UtilError::File(e))?; - dfu.download( - &mut std::fs::OpenOptions::new() - .read(true) - .open("target/out.bin") - .map_err(|e| UtilError::File(e))?, - std::fs::metadata("target/out.bin") - .map_err(|e| UtilError::File(e))? - .len() as u32, - ) - .unwrap(); + dfu.download_from_slice(binary).unwrap(); Ok(()) }