todoist_v2_rest/tasks/structs/task.rs
1use serde::Deserialize;
2
3/// Defines a task as returned by the API. There is no meaning in constructing a task like this
4/// directly (make a `NewTask` or `UpdateTask` struct to make those API calls). Instances of this
5/// are returned by most task-related API calls to show the current state of the task after
6/// the call is finished.
7#[derive(Debug, Deserialize)]
8#[allow(missing_docs)]
9pub struct Task {
10 pub id: String,
11 pub project_id: String,
12 pub section_id: Option<String>,
13 pub content: String,
14 pub description: String,
15 pub is_completed: bool,
16 pub labels: Vec<String>,
17 pub parent_id: Option<String>,
18 pub order: i32,
19 pub priority: u8,
20 pub due: Option<Due>,
21 pub url: String,
22 pub comment_count: u32,
23 pub created_at: String,
24 pub creator_id: String,
25 pub assignee_id: Option<String>,
26 pub assigner_id: Option<String>,
27 pub duration: Option<Duration>,
28}
29
30
31/// Represents the duration of a task. The possible `unit` values are "minute" or "day".
32/// The "amount" field is the number of minutes or days, depending on the unit.
33///
34/// If creating a new task, use NewDuration instead.
35#[derive(Debug, Deserialize)]
36#[allow(missing_docs)]
37pub struct Duration {
38 pub amount: u32,
39 pub unit: String,
40}
41
42
43/// Represents the due date of a task deserialized from the API.
44///
45/// If creating a new task, use `NewDue` instead.
46#[derive(Debug, Deserialize)]
47pub struct Due {
48 /// The string form of the due date, as entered by a user. Its format is arbitrary and user-
49 /// selected.
50 pub string: String,
51
52 /// A date in the format `YYYY-MM-DD`, corrected to the user's timezone.
53 pub date: String,
54
55 /// Whether the task has a recurring due date. If `is_recurring` is `true`, then when this task
56 /// is completed, the next instance of the task will be created with a due-date calculated based
57 /// on the natural-language content of the `string` field.
58 pub is_recurring: bool,
59
60 /// Only returned if an exact due time is set. Conforms to
61 /// [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format.
62 pub datetime: Option<String>,
63
64 /// Only returned if an exact due time is set. It will either be in an IANA Timezone Database
65 /// format (e.g. "Europe/London"), or a UTC offset format ("UTC±HH:MM").
66 pub timezone: Option<String>,
67}
68