Struct irox_progress::Task
source · pub struct Task { /* private fields */ }Implementations§
source§impl Task
impl Task
sourcepub fn new(id: u64, name: String, max_elements: u64) -> Task
pub fn new(id: u64, name: String, max_elements: u64) -> Task
Examples found in repository?
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
pub fn main() -> Result<(), std::io::Error> {
let elements = 1000;
let prog = ConsoleProgressPrinter::new_update_rate(Duration::from_millis(100));
let task = Task::new(0, "Test Task".to_string(), elements);
prog.track_task_progress(&task);
task.mark_started();
for _i in 0..elements {
task.mark_one_completed();
std::thread::sleep(std::time::Duration::from_millis(5));
}
Ok(())
}sourcepub fn current_progress_count(&self) -> u64
pub fn current_progress_count(&self) -> u64
Returns the number of elements completed in the range 0..=max_elements
sourcepub fn max_elements(&self) -> u64
pub fn max_elements(&self) -> u64
Returns the maximum number of elements of this task
sourcepub fn current_progress_frac(&self) -> f64
pub fn current_progress_frac(&self) -> f64
Returns the current progress as a fraction in the range 0..=1
sourcepub fn get_created(&self) -> UnixTimestamp
pub fn get_created(&self) -> UnixTimestamp
Returns the time this task was created
sourcepub fn get_started(&self) -> Option<&UnixTimestamp>
pub fn get_started(&self) -> Option<&UnixTimestamp>
Returns the time at which this task started, or None if the task hasn’t started yet.
sourcepub fn mark_one_completed(&self)
pub fn mark_one_completed(&self)
Increments the ‘completed’ counter.
Examples found in repository?
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
pub fn main() -> Result<(), std::io::Error> {
let elements = 1000;
let prog = ConsoleProgressPrinter::new_update_rate(Duration::from_millis(100));
let task = Task::new(0, "Test Task".to_string(), elements);
prog.track_task_progress(&task);
task.mark_started();
for _i in 0..elements {
task.mark_one_completed();
std::thread::sleep(std::time::Duration::from_millis(5));
}
Ok(())
}sourcepub fn mark_all_completed(&self)
pub fn mark_all_completed(&self)
Mark this task complete. Does not affect sub-tasks.
sourcepub fn mark_started(&self)
pub fn mark_started(&self)
Marks this task as started. If the task has already started, does nothing.
Examples found in repository?
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
pub fn main() -> Result<(), std::io::Error> {
let elements = 1000;
let prog = ConsoleProgressPrinter::new_update_rate(Duration::from_millis(100));
let task = Task::new(0, "Test Task".to_string(), elements);
prog.track_task_progress(&task);
task.mark_started();
for _i in 0..elements {
task.mark_one_completed();
std::thread::sleep(std::time::Duration::from_millis(5));
}
Ok(())
}sourcepub fn get_ended(&self) -> Option<&UnixTimestamp>
pub fn get_ended(&self) -> Option<&UnixTimestamp>
Returns the time at which this task ended, or None if the task hasn’t ended yet.
sourcepub fn mark_ended(&self)
pub fn mark_ended(&self)
Marks this task as ended. If this task has already ended, does nothing.
sourcepub fn num_children(&self) -> usize
pub fn num_children(&self) -> usize
Returns the number of child tasks this task has
sourcepub fn each_child<F: FnMut(&Task)>(&self, func: F)
pub fn each_child<F: FnMut(&Task)>(&self, func: F)
Iterates over each child task, providing a reference of the child task to the input function
sourcepub fn new_child_task(&self, id: u64, name: String, max_elements: u64) -> Task
pub fn new_child_task(&self, id: u64, name: String, max_elements: u64) -> Task
Creates a new child task of this task
sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Returns true if this task is complete.