1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use crate::__export::{ProjectResult, TaskId};
use crate::task::flags::{OptionDeclarations, OptionsDecoder};
use crate::{Project, Task};
/// Create tasks using a project.
pub trait CreateTask: Sized {
/// Creates a new task. The using_id is the id of the task that's being created.
fn new(using_id: &TaskId, project: &Project) -> ProjectResult<Self>;
/// The default description for a Task
fn description() -> String {
String::new()
}
/// When a task is requested with the same name, only the task declared in the current is used
#[doc(hidden)]
fn only_in_current() -> bool {
false
}
/// Gets an optional flags for this task.
///
/// By defaults return `None`
fn options_declarations() -> Option<OptionDeclarations> {
None
}
/// Try to get values from a decoder.
///
/// By default does not do anything.
fn try_set_from_decoder(&mut self, _decoder: &OptionsDecoder) -> ProjectResult<()> {
Ok(())
}
}
impl<T: Default + Task> CreateTask for T {
fn new(_: &TaskId, _: &Project) -> ProjectResult<Self> {
Ok(T::default())
}
}