1use tokio::sync::mpsc;
2
3#[derive(Debug, Default)]
4pub struct Task {
5 pub id: usize,
6 pub kind: TaskKind,
7 pub name: String,
8 pub stage: TaskStage,
9
10 pub total: u32,
11 pub succ: u32,
12 pub fail: u32,
13
14 pub found: u64,
15 pub processed: u64,
16
17 pub logs: String,
18 pub logger: Option<mpsc::UnboundedSender<String>>,
19}
20
21impl Task {
22 pub fn new(id: usize, kind: TaskKind, name: String) -> Self {
23 Self { id, kind, name, ..Default::default() }
24 }
25}
26
27#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
28pub enum TaskKind {
29 #[default]
30 User,
31 Preload,
32}
33
34#[derive(Debug, PartialEq, Eq)]
35pub struct TaskSummary {
36 pub name: String,
37
38 pub total: u32,
39 pub succ: u32,
40 pub fail: u32,
41
42 pub found: u64,
43 pub processed: u64,
44}
45
46impl From<&Task> for TaskSummary {
47 fn from(task: &Task) -> Self {
48 TaskSummary {
49 name: task.name.clone(),
50
51 total: task.total,
52 succ: task.succ,
53 fail: task.fail,
54
55 found: task.found,
56 processed: task.processed,
57 }
58 }
59}
60
61#[derive(Debug)]
62pub enum TaskProg {
63 New(usize, u64),
65 Adv(usize, u32, u64),
67 Succ(usize),
69 Fail(usize, String),
71 Log(usize, String),
73}
74
75#[derive(Clone, Debug, Default, Eq, PartialEq, Ord, PartialOrd)]
76pub enum TaskStage {
77 #[default]
78 Pending,
79 Dispatched,
80 Hooked,
81}