diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-04-27 22:30:04 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-05-04 17:34:37 +0200 |
commit | a7fb8db6baa9c3b687c925b4825a90ec79d2a0db (patch) | |
tree | 4435ecea66392cc3d2a54884b27b74b3666a41e5 | |
parent | be54236d3087c0c2af1e6949a01a2db7f9de8baf (diff) |
Document task module
-rw-r--r-- | src/task.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/task.rs b/src/task.rs index 8aaae17..3e3de39 100644 --- a/src/task.rs +++ b/src/task.rs @@ -17,6 +17,20 @@ use tag::Tag; use date::Date; use annotation::Annotation; +/// Task type +/// +/// A task must have four things: +/// +/// - A Status +/// - An UUID +/// - An Entry-Date +/// - A Description +/// +/// all other Data is optional by taskwarrior. This type is a simple rust representation of the +/// JSON exported by taskwarrior. +/// +/// It is deserializeable and serializeable via serde_json, so importing and exporting taskwarrior +/// tasks is simply serializing and deserializing objects of this type. #[derive(Debug, Clone)] pub struct Task { status : TaskStatus, @@ -48,6 +62,7 @@ pub struct Task { */ impl Task { + /// Create a new Task instance pub fn new( status : TaskStatus, uuid : Uuid, @@ -97,26 +112,32 @@ impl Task { } } + /// Get the status of the task pub fn status(&self) -> &TaskStatus { &self.status } + /// Get the uuid of the task pub fn uuid(&self) -> &Uuid { &self.uuid } + /// Get the entry date of the task pub fn entry(&self) -> &Date { &self.entry } + /// Get the description of the task pub fn description(&self) -> &String { &self.description } + /// Get the annotations of the task pub fn annotations(&self) -> Option<&Vec<Annotation>> { self.annotations.as_ref() } + /// Add an annotation to this task pub fn add_annotation(&mut self, an: Annotation) { if self.annotations.is_none() { self.annotations = Some(vec![an]); @@ -128,68 +149,88 @@ impl Task { } } + /// Add annotations to this task pub fn add_annotations<I: Iterator<Item = Annotation>>(&mut self, i: I) { for item in i { self.add_annotation(item) } } + /// Get the depends of the task + /// + /// This is exported as String by now, which might change in future pub fn depends(&self) -> Option<&String> { self.depends.as_ref() } + /// Get the due date of the task pub fn due(&self) -> Option<&Date> { self.due.as_ref() } + /// Get the end date of the task pub fn end(&self) -> Option<&Date> { self.end.as_ref() } + /// Get the imask of the task pub fn imask(&self) -> Option<&i64> { self.imask.as_ref() } + /// Get the mask of the task pub fn mask(&self) -> Option<&String> { self.mask.as_ref() } + /// Get the modified date of the task pub fn modified(&self) -> Option<&Date> { self.modified.as_ref() } + /// Get the parent of the task pub fn parent(&self) -> Option<&Uuid> { self.parent.as_ref() } + /// Get the priority of the task pub fn priority(&self) -> Option<&TaskPriority> { self.priority.as_ref() } + /// Get the project of the task pub fn project(&self) -> Option<&Project> { self.project.as_ref() } + /// Get the recur of the task + /// + /// This is exported as String by now. This might change in future versions of this crate. pub fn recur(&self) -> Option<&String> { self.recur.as_ref() } + /// Get the scheduled date of the task pub fn scheduled(&self) -> Option<&Date> { self.scheduled.as_ref() } + /// Get the start date of the task pub fn start(&self) -> Option<&Date> { self.start.as_ref() } + /// Get the tags of the task pub fn tags(&self) -> Option<&Vec<Tag>> { self.tags.as_ref() } + /// Get the until date of the task pub fn until(&self) -> Option<&Date> { self.until.as_ref() } + /// Get the wait date of the task pub fn wait(&self) -> Option<&Date> { self.wait.as_ref() } @@ -209,6 +250,7 @@ impl Serialize for Task { } +/// Helper type for task serialization struct TaskVisitor<'a> { value: &'a Task, state: u8, @@ -341,6 +383,7 @@ impl Deserialize for Task { } +/// Helper type for task deserialization struct TaskDeserializeVisitor; impl Visitor for TaskDeserializeVisitor { |