pub struct Task {
pub id: String,
pub title: String,
pub context: String,
pub created_date: DateTime<Local>,
pub priority: i64,
pub notes: Vec<Note>,
pub completed_date: Option<DateTime<Local>>,
pub body: Option<String>,
}
Expand description
Task is the primary data object in taskforge everything works on
or around Tasks. All tasks have an id
field which is a unique
identifier generated as a BSON ObjectID converted to a hex string.
All fields of a task are public however you should not generally change the id of an existing Task.
All tasks implement Serialize and Deserialize from serde.
Additionally Tasks implement Eq, PartialEq, and Ord so given a container of tasks that allows for sorting one can sort the Tasks by priority descending followed by oldest created date first.
Fields§
§id: String
§title: String
§context: String
§created_date: DateTime<Local>
§priority: i64
§notes: Vec<Note>
§completed_date: Option<DateTime<Local>>
§body: Option<String>
Implementations§
Source§impl Task
impl Task
Sourcepub fn new(title: &str) -> Task
pub fn new(title: &str) -> Task
Create a new Task
with title
.
This function will auto generate a BSON ObjectID as well as set other fields to their default values.
The Default values are as follows:
Field | Type | Default Value |
---|---|---|
id | String | BSON ObjectID |
context | String | "default" |
created_date | Chrono::DateTime<Local> | current local time created with Chrono::Local::now() |
completed_date | Option<Chrono::DateTime<Local>> | None |
priority | f64 | 1.0 |
notes | Vec<Note> | [] |
body | String | "" |
Sourcepub fn with_context(self, context: &str) -> Task
pub fn with_context(self, context: &str) -> Task
Change the context of a task during creation using the builder pattern.
Sourcepub fn with_priority(self, priority: i64) -> Task
pub fn with_priority(self, priority: i64) -> Task
Change the priority of a task during creation using the builder pattern.
Sourcepub fn with_body(self, body: &str) -> Task
pub fn with_body(self, body: &str) -> Task
Change the body of a task during creation using the builder pattern.
Sourcepub fn precomplete(self) -> Task
pub fn precomplete(self) -> Task
Complete a task during creation using the builder pattern.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Task
impl<'de> Deserialize<'de> for Task
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Ord for Task
impl Ord for Task
Source§impl PartialOrd for Task
impl PartialOrd for Task
impl Eq for Task
impl StructuralPartialEq for Task
Auto Trait Implementations§
impl Freeze for Task
impl RefUnwindSafe for Task
impl Send for Task
impl Sync for Task
impl Unpin for Task
impl UnwindSafe for Task
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.