summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-09-19 14:37:03 +0200
committerGitHub <noreply@github.com>2017-09-19 14:37:03 +0200
commitac6f1733f6eafacad44153aba683fdd2f21b7f46 (patch)
tree3468761ae02cba589a7078479dacb1adc4efbf7b
parent2173b55e9d0fdea1f6d9170a6939e39e95024148 (diff)
parentaaf884ec3aebbefd327c8091ac6407a19558f42b (diff)
Merge pull request #53 from matthiasbeyer/rw-interface
Implement a RW interface
-rw-r--r--src/annotation.rs10
-rw-r--r--src/task.rs112
2 files changed, 109 insertions, 13 deletions
diff --git a/src/annotation.rs b/src/annotation.rs
index 5f43e2d..eb108e3 100644
--- a/src/annotation.rs
+++ b/src/annotation.rs
@@ -32,11 +32,21 @@ impl Annotation {
&self.entry
}
+ /// Get the entry date mutable
+ pub fn entry_mut(&mut self) -> &mut Date {
+ &mut self.entry
+ }
+
/// Get the description text
pub fn description(&self) -> &String {
&self.description
}
+ /// Get the description text mutable
+ pub fn description_mut(&mut self) -> &mut String {
+ &mut self.description
+ }
+
}
#[cfg(test)]
diff --git a/src/task.rs b/src/task.rs
index 6d2b566..cb2b806 100644
--- a/src/task.rs
+++ b/src/task.rs
@@ -146,39 +146,49 @@ impl Task {
&self.status
}
+ /// Get the status of the task mutable
+ pub fn status_mut(&mut self) -> &mut TaskStatus {
+ &mut self.status
+ }
+
/// Get the uuid of the task
pub fn uuid(&self) -> &Uuid {
&self.uuid
}
+ /// Get the uuid of the task mutable
+ pub fn uuid_mut(&mut self) -> &mut Uuid {
+ &mut self.uuid
+ }
+
/// Get the entry date of the task
pub fn entry(&self) -> &Date {
&self.entry
}
+ /// Get the entry date of the task mutable
+ pub fn entry_mut(&mut self) -> &mut Date {
+ &mut self.entry
+ }
+
/// Get the description of the task
pub fn description(&self) -> &String {
&self.description
}
+ /// Get the description of the task mutable
+ pub fn description_mut(&mut self) -> &mut String {
+ &mut 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) {
- match self.annotations {
- None => self.annotations = Some(vec![an]),
- Some(ref mut n) => n.push(an),
- }
- }
-
- /// 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 annotations of the task mutable
+ pub fn annotations_mut(&mut self) -> Option<&mut Vec<Annotation>> {
+ self.annotations.as_mut()
}
/// Get the depends of the task
@@ -188,46 +198,91 @@ impl Task {
self.depends.as_ref()
}
+ /// This is exported as String by now, which might change in future mutable
+ pub fn depends_mut(&mut self) -> Option<&mut String> {
+ self.depends.as_mut()
+ }
+
/// Get the due date of the task
pub fn due(&self) -> Option<&Date> {
self.due.as_ref()
}
+ /// Get the due date of the task mutable
+ pub fn due_mut(&mut self) -> Option<&mut Date> {
+ self.due.as_mut()
+ }
+
/// Get the end date of the task
pub fn end(&self) -> Option<&Date> {
self.end.as_ref()
}
+ /// Get the end date of the task mutable
+ pub fn end_mut(&mut self) -> Option<&mut Date> {
+ self.end.as_mut()
+ }
+
/// Get the imask of the task
pub fn imask(&self) -> Option<&i64> {
self.imask.as_ref()
}
+ /// Get the imask of the task mutable
+ pub fn imask_mut(&mut self) -> Option<&mut i64> {
+ self.imask.as_mut()
+ }
+
/// Get the mask of the task
pub fn mask(&self) -> Option<&String> {
self.mask.as_ref()
}
+ /// Get the mask of the task mutable
+ pub fn mask_mut(&mut self) -> Option<&mut String> {
+ self.mask.as_mut()
+ }
+
/// Get the modified date of the task
pub fn modified(&self) -> Option<&Date> {
self.modified.as_ref()
}
+ /// Get the modified date of the task mutable
+ pub fn modified_mut(&mut self) -> Option<&mut Date> {
+ self.modified.as_mut()
+ }
+
/// Get the parent of the task
pub fn parent(&self) -> Option<&Uuid> {
self.parent.as_ref()
}
+ /// Get the parent of the task mutable
+ pub fn parent_mut(&mut self) -> Option<&mut Uuid> {
+ self.parent.as_mut()
+ }
+
/// Get the priority of the task
pub fn priority(&self) -> Option<&TaskPriority> {
self.priority.as_ref()
}
+ /// Get the priority of the task mutable
+ pub fn priority_mut(&mut self) -> Option<&mut TaskPriority> {
+ self.priority.as_mut()
+ }
+
/// Get the project of the task
pub fn project(&self) -> Option<&Project> {
self.project.as_ref()
}
+ /// Get the project of the task mutable
+ pub fn project_mut(&mut self) -> Option<&mut Project> {
+ self.project.as_mut()
+ }
+
/// Get the recur of the task
///
/// This is exported as String by now. This might change in future versions of this crate.
@@ -235,31 +290,62 @@ impl Task {
self.recur.as_ref()
}
+ /// This is exported as String by now. This might change in future versions of this crate.
+ /// mutable
+ pub fn recur_mut(&mut self) -> Option<&mut String> {
+ self.recur.as_mut()
+ }
+
/// Get the scheduled date of the task
pub fn scheduled(&self) -> Option<&Date> {
self.scheduled.as_ref()
}
+ /// Get the scheduled date of the task mutable
+ pub fn scheduled_mut(&mut self) -> Option<&mut Date> {
+ self.scheduled.as_mut()
+ }
+
/// Get the start date of the task
pub fn start(&self) -> Option<&Date> {
self.start.as_ref()
}
+ /// Get the start date of the task mutable
+ pub fn start_mut(&mut self) -> Option<&mut Date> {
+ self.start.as_mut()
+ }
+
/// Get the tags of the task
pub fn tags(&self) -> Option<&Vec<Tag>> {
self.tags.as_ref()
}
+ /// Get the tags of the task mutable
+ pub fn tags_mut(&mut self) -> Option<&mut Vec<Tag>> {
+ self.tags.as_mut()
+ }
+
/// Get the until date of the task
pub fn until(&self) -> Option<&Date> {
self.until.as_ref()
}
+ /// Get the until date of the task mutable
+ pub fn until_mut(&mut self) -> Option<&mut Date> {
+ self.until.as_mut()
+ }
+
/// Get the wait date of the task
pub fn wait(&self) -> Option<&Date> {
self.wait.as_ref()
}
+ /// Get the wait date of the task mutable
+ pub fn wait_mut(&mut self) -> Option<&mut Date> {
+ self.wait.as_mut()
+ }
+
}
#[cfg(test)]