assemble_core/defaults/
tasks.rs

1//! The default tasks included in assemble
2
3use crate::task::task_io::TaskIO;
4use crate::task::up_to_date::UpToDate;
5use crate::{BuildResult, Executable, Project, Task};
6use std::collections::HashMap;
7use std::fmt::Debug;
8
9mod help;
10mod tasks_report;
11mod wrapper;
12
13use crate::task::create_task::CreateTask;
14use crate::task::initialize_task::InitializeTask;
15pub use help::Help;
16pub use tasks_report::TaskReport;
17pub use wrapper::WrapperTask;
18
19/// A task that has no actions by default.
20#[derive(Debug, Default)]
21pub struct Empty;
22
23impl UpToDate for Empty {}
24
25impl InitializeTask for Empty {}
26
27impl TaskIO for Empty {}
28
29impl Task for Empty {
30    fn task_action(_task: &mut Executable<Self>, _project: &Project) -> BuildResult {
31        Ok(())
32    }
33}
34
35/// A basic task is a task that by default only contains a hashmap of data.
36#[derive(Debug)]
37pub struct Basic<T: Debug> {
38    map: HashMap<String, T>,
39}
40
41impl<T: Debug> Basic<T> {
42    pub fn map(&self) -> &HashMap<String, T> {
43        &self.map
44    }
45
46    pub fn map_mut(&mut self) -> &mut HashMap<String, T> {
47        &mut self.map
48    }
49}
50
51impl<T: Debug> Default for Basic<T> {
52    fn default() -> Self {
53        Self {
54            map: HashMap::new(),
55        }
56    }
57}
58
59impl<T: Debug> UpToDate for Basic<T> {}
60
61impl<T: Debug> InitializeTask for Basic<T> {}
62
63impl<T: Debug> TaskIO for Basic<T> {}
64
65impl<T: Debug> Task for Basic<T> {
66    fn task_action(_task: &mut Executable<Self>, _project: &Project) -> BuildResult {
67        Ok(())
68    }
69}