Skip to content

Commit

Permalink
Fix some clippy warnings, documentation updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jessebraham committed Jan 12, 2023
1 parent 421a8dc commit 770b2f8
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# espflash

![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/esp-rs/espflash/rust.yml?branch=main&logoColor=1C2C2E&style=flat-square)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/esp-rs/espflash/rust.yml?branch=main&labelColor=1C2C2E&logo=github&style=flat-square)
![Crates.io](https://img.shields.io/crates/l/espflash?labelColor=1C2C2E&style=flat-square)
[![Matrix](https://img.shields.io/matrix/esp-rs:matrix.org?label=join%20matrix&color=BEC5C9&labelColor=1C2C2E&logo=matrix&style=flat-square)](https://matrix.to/#/#esp-rs:matrix.org)

Expand Down
2 changes: 2 additions & 0 deletions espflash/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Send commands to a target device

use std::{io::Write, mem::size_of, time::Duration};

use bytemuck::{bytes_of, Pod, Zeroable};
Expand Down
12 changes: 9 additions & 3 deletions espflash/src/targets/flash_target/esp32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ impl FlashTarget for Esp32Target {
let chunks = compressed.chunks(flash_write_size);
let num_chunks = chunks.len();

progress.as_mut().map(|cb| cb.init(addr, num_chunks));
if let Some(cb) = progress.as_mut() {
cb.init(addr, num_chunks)
}

// decode the chunks to see how much data the device will have to save
let mut decoder = ZlibDecoder::new(Vec::new());
Expand All @@ -156,10 +158,14 @@ impl FlashTarget for Esp32Target {
},
)?;

progress.as_mut().map(|cb| cb.update(i + 1));
if let Some(cb) = progress.as_mut() {
cb.update(i + 1)
}
}

progress.as_mut().map(|cb| cb.finish());
if let Some(cb) = progress.as_mut() {
cb.finish()
}

Ok(())
}
Expand Down
12 changes: 9 additions & 3 deletions espflash/src/targets/flash_target/esp8266.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ impl FlashTarget for Esp8266Target {
let chunks = segment.data.chunks(FLASH_WRITE_SIZE);
let num_chunks = chunks.len();

progress.as_mut().map(|cb| cb.init(addr, num_chunks));
if let Some(cb) = progress.as_mut() {
cb.init(addr, num_chunks)
}

for (i, block) in chunks.enumerate() {
connection.command(Command::FlashData {
Expand All @@ -67,10 +69,14 @@ impl FlashTarget for Esp8266Target {
data: block,
})?;

progress.as_mut().map(|cb| cb.update(i + 1));
if let Some(cb) = progress.as_mut() {
cb.update(i + 1)
}
}

progress.as_mut().map(|cb| cb.finish());
if let Some(cb) = progress.as_mut() {
cb.finish()
}

Ok(())
}
Expand Down
12 changes: 9 additions & 3 deletions espflash/src/targets/flash_target/ram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ impl FlashTarget for RamTarget {
let chunks = segment.data.chunks(self.block_size);
let num_chunks = chunks.len();

progress.as_mut().map(|cb| cb.init(addr, num_chunks));
if let Some(cb) = progress.as_mut() {
cb.init(addr, num_chunks)
}

for (i, block) in chunks.enumerate() {
connection.command(Command::MemData {
Expand All @@ -73,10 +75,14 @@ impl FlashTarget for RamTarget {
data: block,
})?;

progress.as_mut().map(|cb| cb.update(i + 1));
if let Some(cb) = progress.as_mut() {
cb.update(i + 1)
}
}

progress.as_mut().map(|cb| cb.finish());
if let Some(cb) = progress.as_mut() {
cb.finish()
}

Ok(())
}
Expand Down

0 comments on commit 770b2f8

Please sign in to comment.