pub struct Item { /* private fields */ }
Expand description
An item in a todo list.
§Examples
use tada::{Importance, Item};
let i = Item::parse("(A) clean my @home");
assert_eq!(Some(Importance::A), i.importance());
assert_eq!("clean my @home", i.description());
assert!(i.has_context("home"));
Implementations§
Source§impl Item
impl Item
pub fn new() -> Item
Sourcepub fn parse(text: &str) -> Item
pub fn parse(text: &str) -> Item
Parse an item from a line of text.
Assumes the todo.txt format.
Sourcepub fn but_done(&self, include_date: bool) -> Item
pub fn but_done(&self, include_date: bool) -> Item
Create a version of this item but representing a completed task.
Sourcepub fn but_pull(&self, new_urgency: Urgency) -> Item
pub fn but_pull(&self, new_urgency: Urgency) -> Item
Pull a task forward to being done with a new urgency, also clearing any start date.
Sourcepub fn fixup(&self, warnings: bool) -> Item
pub fn fixup(&self, warnings: bool) -> Item
Performs a bunch of small fixes on the item syntax.
Sourcepub fn completion(&self) -> bool
pub fn completion(&self) -> bool
Whether the task is complete.
Sourcepub fn set_completion(&mut self, x: bool)
pub fn set_completion(&mut self, x: bool)
Set indicator of whether the task is complete.
Sourcepub fn line_number(&self) -> usize
pub fn line_number(&self) -> usize
Line number indicator (sometimes zero).
Sourcepub fn set_line_number(&mut self, x: usize)
pub fn set_line_number(&mut self, x: usize)
Set line number indicator for the task.
Sourcepub fn priority(&self) -> char
pub fn priority(&self) -> char
Task priority/importance as given in a todo.txt file.
A is highest, then B and C. D should be considered normal. E is low priority. Any uppercase letter is valid, but letters after E are not especially meaningful.
The importance() method is better.
Sourcepub fn set_priority(&mut self, x: char)
pub fn set_priority(&mut self, x: char)
Set task priority.
Sourcepub fn completion_date(&self) -> Option<NaiveDate>
pub fn completion_date(&self) -> Option<NaiveDate>
Completion date.
Often none.
Sourcepub fn set_completion_date(&mut self, x: NaiveDate)
pub fn set_completion_date(&mut self, x: NaiveDate)
Set the completion date to a given date.
Sourcepub fn clear_completion_date(&mut self)
pub fn clear_completion_date(&mut self)
Set the completion date to None.
Sourcepub fn creation_date(&self) -> Option<NaiveDate>
pub fn creation_date(&self) -> Option<NaiveDate>
Task creation date.
Often none.
Sourcepub fn set_creation_date(&mut self, x: NaiveDate)
pub fn set_creation_date(&mut self, x: NaiveDate)
Set the task creation date to a given date.
Sourcepub fn clear_creation_date(&mut self)
pub fn clear_creation_date(&mut self)
Set the task creation date to None.
Sourcepub fn description(&self) -> String
pub fn description(&self) -> String
Task description.
Sourcepub fn set_description(&mut self, x: String)
pub fn set_description(&mut self, x: String)
Set the task description.
Internally clears cached tags, etc.
Sourcepub fn importance(&self) -> Option<Importance>
pub fn importance(&self) -> Option<Importance>
Return the importance of this task.
Basically the same as priority, except it’s an enum and all letters after E are treated as being the same as E.
Sourcepub fn set_importance(&mut self, i: Importance)
pub fn set_importance(&mut self, i: Importance)
Set the item’s importance.
Sourcepub fn clear_importance(&mut self)
pub fn clear_importance(&mut self)
Set the item’s importance.
Sourcepub fn start_date(&self) -> Option<NaiveDate>
pub fn start_date(&self) -> Option<NaiveDate>
Return the date when this task may be started.
Sourcepub fn is_startable(&self) -> bool
pub fn is_startable(&self) -> bool
A task is startable if it doesn’t have a start date which is in the future.
Sourcepub fn set_urgency(&mut self, urg: Urgency)
pub fn set_urgency(&mut self, urg: Urgency)
Set task urgency.
Sourcepub fn tshirt_size(&self) -> Option<TshirtSize>
pub fn tshirt_size(&self) -> Option<TshirtSize>
Return the size of this task.
Tags.
Sourcepub fn has_tag(&self, tag: &str) -> bool
pub fn has_tag(&self, tag: &str) -> bool
Boolean indicating whether a task has a particular tag.
Sourcepub fn has_context(&self, ctx: &str) -> bool
pub fn has_context(&self, ctx: &str) -> bool
Boolean indicating whether a task has a particular context.
Sourcepub fn smart_key(&self) -> (Urgency, Importance, TshirtSize)
pub fn smart_key(&self) -> (Urgency, Importance, TshirtSize)
Key used for smart sorting