Skip to main content

multiples/
multiples.rs

1use std::time::Duration;
2use waitforit::Wait;
3
4fn main() {
5    // Wait for foo.txt to exist
6    let foo_exists = Wait::new_file_exists("foo.txt");
7
8    // And for foo.txt to stop being updated (considering it done if it's not been updated in at least 10sec).
9    let foo_done = !Wait::new_file_update_since("foo.txt", Duration::from_secs(10));
10
11    // Require these two conditions together (in order):
12    let foo = foo_exists & foo_done;
13
14    // No more than 30 seconds of elapsed time:
15    let bar = Wait::new_elapsed_from_duration(Duration::from_secs(30));
16
17    // Block until either foo or bar has completed, checking them every 1 second
18    (foo | bar).wait(Duration::from_secs(1));
19}