Struct Item

Source
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

Source

pub fn new() -> Item

Source

pub fn parse(text: &str) -> Item

Parse an item from a line of text.

Assumes the todo.txt format.

Source

pub fn but_done(&self, include_date: bool) -> Item

Create a version of this item but representing a completed task.

Source

pub fn zen(&self) -> Item

Provide zen-like calm by rescheduling an overdue task.

Source

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.

Source

pub fn fixup(&self, warnings: bool) -> Item

Performs a bunch of small fixes on the item syntax.

Source

pub fn completion(&self) -> bool

Whether the task is complete.

Source

pub fn set_completion(&mut self, x: bool)

Set indicator of whether the task is complete.

Source

pub fn line_number(&self) -> usize

Line number indicator (sometimes zero).

Source

pub fn set_line_number(&mut self, x: usize)

Set line number indicator for the task.

Source

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.

Source

pub fn set_priority(&mut self, x: char)

Set task priority.

Source

pub fn completion_date(&self) -> Option<NaiveDate>

Completion date.

Often none.

Source

pub fn set_completion_date(&mut self, x: NaiveDate)

Set the completion date to a given date.

Source

pub fn clear_completion_date(&mut self)

Set the completion date to None.

Source

pub fn creation_date(&self) -> Option<NaiveDate>

Task creation date.

Often none.

Source

pub fn set_creation_date(&mut self, x: NaiveDate)

Set the task creation date to a given date.

Source

pub fn clear_creation_date(&mut self)

Set the task creation date to None.

Source

pub fn description(&self) -> String

Task description.

Source

pub fn set_description(&mut self, x: String)

Set the task description.

Internally clears cached tags, etc.

Source

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.

Source

pub fn set_importance(&mut self, i: Importance)

Set the item’s importance.

Source

pub fn clear_importance(&mut self)

Set the item’s importance.

Source

pub fn due_date(&self) -> Option<NaiveDate>

Return the date when this task is due by.

Source

pub fn start_date(&self) -> Option<NaiveDate>

Return the date when this task may be started.

Source

pub fn is_startable(&self) -> bool

A task is startable if it doesn’t have a start date which is in the future.

Source

pub fn urgency(&self) -> Option<Urgency>

Classify how urgent this task is.

Source

pub fn set_urgency(&mut self, urg: Urgency)

Set task urgency.

Source

pub fn tshirt_size(&self) -> Option<TshirtSize>

Return the size of this task.

Source

pub fn tags(&self) -> Vec<String>

Tags.

Source

pub fn has_tag(&self, tag: &str) -> bool

Boolean indicating whether a task has a particular tag.

Source

pub fn contexts(&self) -> Vec<String>

Contexts.

Source

pub fn has_context(&self, ctx: &str) -> bool

Boolean indicating whether a task has a particular context.

Source

pub fn kv(&self) -> HashMap<String, String>

Key-Value Tags.

Source

pub fn smart_key(&self) -> (Urgency, Importance, TshirtSize)

Key used for smart sorting

Trait Implementations§

Source§

impl Clone for Item

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Item

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Debugging output; used for format!(“{:?}”)

Source§

impl Default for Item

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for Item

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

File-ready output; used for format!(“{}”)

Auto Trait Implementations§

§

impl !Freeze for Item

§

impl RefUnwindSafe for Item

§

impl Send for Item

§

impl Sync for Item

§

impl Unpin for Item

§

impl UnwindSafe for Item

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T