diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-07-07 13:35:16 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-07-07 13:35:50 +0200 |
commit | 434c66a517f086e24f1885cfff04fe8c00bd98a7 (patch) | |
tree | 939babd1c600c7bfe04b53af64c8f881f514c4d1 /src/util.rs | |
parent | 38e008d788231660f5a4c7790c18016f8e3bc7f9 (diff) |
Move State from loadinglist to util module, remove Progress type
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/util.rs')
-rw-r--r-- | src/util.rs | 46 |
1 files changed, 11 insertions, 35 deletions
diff --git a/src/util.rs b/src/util.rs index 19b50fe..1abb071 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,45 +1,21 @@ use std::fmt::Debug; -#[derive(Clone, Debug)] -pub struct Progress -{ - current: usize, - complete: usize, - is_complete: bool, +#[derive(Debug)] +pub enum State<D: Debug + Sized> { + Processing(D), + Ready } -impl Progress +impl<D> State<D> + where D: Debug + Sized { - pub fn with_complete(complete: usize) -> Progress { - Progress { current: 0, complete, is_complete: false } - } - - pub fn is(current: usize, complete: usize) -> Progress { - Progress { current, complete, current == complete } - } - - pub fn new_complete() -> Progress { - Progress { current: 0, complete: 0, is_complete: true } - } - - pub fn is_complete(&self) -> bool { - self.is_complete + pub fn processing(d: D) -> Self { + State::Processing(d) } - pub fn set_complete(&mut self, c: bool) { - self.is_complete = c; - } - - pub fn step(&mut self) { - self.current += 1; - } - - pub fn current(&self) -> usize { - self.current - } - - pub fn complete(&self) -> usize { - self.complete + pub fn ready() -> Self { + State::Ready } } + |