Skip to content

Commit

Permalink
fix: wait for scan job to finish in example
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI committed Oct 19, 2024
1 parent b15281e commit de53577
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

13 changes: 11 additions & 2 deletions examples/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::{io::Write, time::Duration};
use escl::{
discover,
settings::{ContentRegionUnits, InputSource, ScanRegion, ScanRegions},
status::ScannerState,
Scanner,
};

Expand Down Expand Up @@ -60,8 +61,16 @@ async fn main() {
.expect("unable to submit scan job");
println!("Scan job URL: {}", job.job_url());

let status = scanner.status().await.expect("unable to fetch status");
println!("Scanner status: \n{:#?}", status);
loop {
let status = scanner.status().await.expect("unable to fetch status");
println!("Scanner status: \n{:#?}", status);

if status.state != ScannerState::Processing {
break;
}

tokio::time::sleep(Duration::from_secs(1)).await;
}

println!("Downloading scanned page...");
let image = job
Expand Down

0 comments on commit de53577

Please sign in to comment.