Skip to content

Commit

Permalink
examples: Don't rely on progress info from dfu-nusb
Browse files Browse the repository at this point in the history
Let indicatif wrap the AsyncReader to get progress information as
opposed to using the callback from dfu-nusb
  • Loading branch information
sjoerdsimons committed Oct 31, 2024
1 parent 58217fb commit 1792eb4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ readme = "README.md"
[dependencies]
dfu-core = { version = "0.6.0", features = ["async"] }
futures = { version = "0.3.31", features = ["io-compat"] }
indicatif = "0.17.8"
indicatif = { version = "0.17.8", features = [ "tokio" ] }
nusb = "0.1.10"
thiserror = "1.0.65"
tokio = { version = "1.41.0", features = ["full"] }
Expand Down
11 changes: 1 addition & 10 deletions examples/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,11 @@ pub async fn run(opts: Cli) -> anyhow::Result<()> {
.progress_chars("#>-"),
);

device.with_progress({
let bar = bar.clone();
move |count| {
bar.inc(count as u64);
if bar.position() == file_size as u64 {
bar.finish();
}
}
});

if let Some(address) = override_address {
device.override_address(address);
}

let file = bar.wrap_async_read(file);
let file = file.compat();
match device.download(file, file_size).await {
Ok(_) => (),
Expand Down

0 comments on commit 1792eb4

Please sign in to comment.