task_hookrs/annotation.rs
1//
2// This Source Code Form is subject to the terms of the Mozilla Public
3// License, v. 2.0. If a copy of the MPL was not distributed with this
4// file, You can obtain one at http://mozilla.org/MPL/2.0/.
5//
6
7//! Module containing types and functions for annotations of tasks
8
9use crate::date::Date;
10
11/// Annotation type for task annotations.
12/// Each annotation in taskwarrior consists of a date and a description,
13/// the date is named "entry", the description "description" in the JSON export.
14#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Eq, PartialEq)]
15pub struct Annotation {
16 entry: Date,
17 description: String,
18}
19
20impl Annotation {
21 /// Create a new Annotation object
22 pub fn new(entry: Date, description: String) -> Annotation {
23 Annotation { entry, description }
24 }
25
26 /// Get the entry date
27 pub fn entry(&self) -> &Date {
28 &self.entry
29 }
30
31 /// Get the entry date mutable
32 pub fn entry_mut(&mut self) -> &mut Date {
33 &mut self.entry
34 }
35
36 /// Get the description text
37 pub fn description(&self) -> &String {
38 &self.description
39 }
40
41 /// Get the description text mutable
42 pub fn description_mut(&mut self) -> &mut String {
43 &mut self.description
44 }
45}
46
47#[cfg(test)]
48mod test {}