summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalte Brandy <malte.brandy@maralorn.de>2018-04-30 20:13:30 +0200
committerMalte Brandy <malte.brandy@maralorn.de>2018-04-30 20:13:30 +0200
commit53ec0a5a99316877f39c9897eff039d7316bd794 (patch)
tree0fbf592cf629847a498cde7bf7802ba770a9dfaf
parent3a61225d9d434d4d1f8787649b439f56b073f1a7 (diff)
Add setters
-rw-r--r--src/task.rs132
1 files changed, 132 insertions, 0 deletions
diff --git a/src/task.rs b/src/task.rs
index c2317e0..02d374c 100644
--- a/src/task.rs
+++ b/src/task.rs
@@ -226,6 +226,15 @@ impl Task {
self.annotations.as_mut()
}
+ /// Set annotations
+ pub fn set_annotations<T, A>(&mut self, new: Option<T>)
+ where
+ T: IntoIterator,
+ T::Item: Into<Annotation>,
+ {
+ self.annotations = new.map(|x| x.into_iter().map(Into::into).collect());
+ }
+
/// Get the dependencies of the task
pub fn depends(&self) -> Option<&Vec<Uuid>> {
self.depends.as_ref()
@@ -236,6 +245,15 @@ impl Task {
self.depends.as_mut()
}
+ /// Set depends
+ pub fn set_depends<T, U>(&mut self, new: Option<T>)
+ where
+ T: IntoIterator,
+ T::Item: Into<Uuid>,
+ {
+ self.depends = new.map(|x| x.into_iter().map(Into::into).collect());
+ }
+
/// Get the due date of the task
pub fn due(&self) -> Option<&Date> {
self.due.as_ref()
@@ -246,6 +264,14 @@ impl Task {
self.due.as_mut()
}
+ /// Set due
+ pub fn set_due<T>(&mut self, new: Option<T>)
+ where
+ T: Into<Date>,
+ {
+ self.due = new.map(Into::into)
+ }
+
/// Get the end date of the task
pub fn end(&self) -> Option<&Date> {
self.end.as_ref()
@@ -256,6 +282,14 @@ impl Task {
self.end.as_mut()
}
+ /// Set end
+ pub fn set_end<T>(&mut self, new: Option<T>)
+ where
+ T: Into<Date>,
+ {
+ self.end = new.map(Into::into)
+ }
+
/// Get the imask of the task
pub fn imask(&self) -> Option<&i64> {
self.imask.as_ref()
@@ -266,6 +300,14 @@ impl Task {
self.imask.as_mut()
}
+ /// Set imask
+ pub fn set_imask<T>(&mut self, new: Option<T>)
+ where
+ T: Into<i64>,
+ {
+ self.imask = new.map(Into::into)
+ }
+
/// Get the mask of the task
pub fn mask(&self) -> Option<&String> {
self.mask.as_ref()
@@ -276,6 +318,14 @@ impl Task {
self.mask.as_mut()
}
+ /// Set mask
+ pub fn set_mask<T>(&mut self, new: Option<T>)
+ where
+ T: Into<String>,
+ {
+ self.mask = new.map(Into::into)
+ }
+
/// Get the modified date of the task
pub fn modified(&self) -> Option<&Date> {
self.modified.as_ref()
@@ -286,6 +336,14 @@ impl Task {
self.modified.as_mut()
}
+ /// Set modified
+ pub fn set_modified<T>(&mut self, new: Option<T>)
+ where
+ T: Into<Date>,
+ {
+ self.modified = new.map(Into::into)
+ }
+
/// Get the parent of the task
pub fn parent(&self) -> Option<&Uuid> {
self.parent.as_ref()
@@ -296,6 +354,14 @@ impl Task {
self.parent.as_mut()
}
+ /// Set parent
+ pub fn set_parent<T>(&mut self, new: Option<T>)
+ where
+ T: Into<Uuid>,
+ {
+ self.parent = new.map(Into::into)
+ }
+
/// Get the priority of the task
pub fn priority(&self) -> Option<&TaskPriority> {
self.priority.as_ref()
@@ -306,6 +372,14 @@ impl Task {
self.priority.as_mut()
}
+ /// Set priority
+ pub fn set_priority<T>(&mut self, new: Option<T>)
+ where
+ T: Into<TaskPriority>,
+ {
+ self.priority = new.map(Into::into)
+ }
+
/// Get the project of the task
pub fn project(&self) -> Option<&Project> {
self.project.as_ref()
@@ -316,6 +390,14 @@ impl Task {
self.project.as_mut()
}
+ /// Set project
+ pub fn set_project<T>(&mut self, new: Option<T>)
+ where
+ T: Into<Project>,
+ {
+ self.project = new.map(Into::into)
+ }
+
/// Get the recur of the task
///
/// This is exported as String by now. This might change in future versions of this crate.
@@ -329,6 +411,14 @@ impl Task {
self.recur.as_mut()
}
+ /// Set recur
+ pub fn set_recur<T>(&mut self, new: Option<T>)
+ where
+ T: Into<String>,
+ {
+ self.recur = new.map(Into::into)
+ }
+
/// Get the scheduled date of the task
pub fn scheduled(&self) -> Option<&Date> {
self.scheduled.as_ref()
@@ -339,6 +429,14 @@ impl Task {
self.scheduled.as_mut()
}
+ /// Set scheduled
+ pub fn set_scheduled<T>(&mut self, new: Option<T>)
+ where
+ T: Into<Date>,
+ {
+ self.scheduled = new.map(Into::into)
+ }
+
/// Get the start date of the task
pub fn start(&self) -> Option<&Date> {
self.start.as_ref()
@@ -349,6 +447,14 @@ impl Task {
self.start.as_mut()
}
+ /// Set start
+ pub fn set_start<T>(&mut self, new: Option<T>)
+ where
+ T: Into<Date>,
+ {
+ self.start = new.map(Into::into)
+ }
+
/// Get the tags of the task
pub fn tags(&self) -> Option<&Vec<Tag>> {
self.tags.as_ref()
@@ -359,6 +465,15 @@ impl Task {
self.tags.as_mut()
}
+ /// Set tags
+ pub fn set_tags<T, K>(&mut self, new: Option<T>)
+ where
+ T: IntoIterator,
+ T::Item: Into<Tag>,
+ {
+ self.tags = new.map(|x| x.into_iter().map(Into::into).collect());
+ }
+
/// Get the until date of the task
pub fn until(&self) -> Option<&Date> {
self.until.as_ref()
@@ -369,6 +484,14 @@ impl Task {
self.until.as_mut()
}
+ /// Set until
+ pub fn set_until<T>(&mut self, new: Option<T>)
+ where
+ T: Into<Date>,
+ {
+ self.until = new.map(Into::into);
+ }
+
/// Get the wait date of the task
pub fn wait(&self) -> Option<&Date> {
self.wait.as_ref()
@@ -378,6 +501,15 @@ impl Task {
pub fn wait_mut(&mut self) -> Option<&mut Date> {
self.wait.as_mut()
}
+
+ /// Set wait
+ pub fn set_wait<T>(&mut self, new: Option<T>)
+ where
+ T: Into<Date>,
+ {
+ self.wait = new.map(Into::into);
+ }
+
/// Get the BTreeMap that contains the UDA
pub fn uda(&self) -> &UDA {
&self.uda