Skip to main content

Task

Struct Task 

Source
#[non_exhaustive]
pub struct Task {
Show 16 fields pub id: u32, pub kind: Kind, pub title: String, pub tags: Vec<String>, pub links: Vec<u32>, pub repo_links: Vec<RepoLink>, pub status: Status, pub decision: DecisionState, pub created: DateTime<Local>, pub description: String, pub comments: Vec<Comment>, pub history: Vec<StatusChange>, pub activity: Vec<Activity>, pub sessions: Vec<Session>, pub path: Option<PathBuf>, pub unknown: Unknown,
}
Expand description

An entry: a task, note or decision. What it is, how it’s tagged and linked, and for tasks, where it stands and how it got there.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§id: u32

Unique number across all kinds, also the start of the file name.

§kind: Kind

Task, note or decision.

§title: String

One-line title.

§tags: Vec<String>

Lowercase, without the leading #.

§links: Vec<u32>

Ids of related entries, in the order they were added. Deleting an entry removes the links to it.

§repo_links: Vec<RepoLink>

Related entries in the project’s other repositories, in the order they were added. Nothing checks them once written: the other repository may be elsewhere, or the entry deleted there since.

§status: Status

Where the task stands.

§decision: DecisionState

Decisions only: whether it’s in force, proposed or rejected.

§created: DateTime<Local>

When the task was created.

§description: String

Free text describing the task.

§comments: Vec<Comment>

Oldest first.

§history: Vec<StatusChange>

Every status change, oldest first.

§activity: Vec<Activity>

Every change to the title, tags, related entries or description, oldest first.

§sessions: Vec<Session>

Tracked work, oldest first; only the last one can be open, and only while the task is doing.

§path: Option<PathBuf>

File this task was loaded from / saved to.

§unknown: Unknown

What the file holds that this version doesn’t understand, written back as it was.

Implementations§

Source§

impl Task

Source

pub fn to_markdown(&self) -> String

The task as a markdown file (see the format at the top of this module).

Source

pub fn from_markdown(text: &str) -> Result<Task, String>

Parses a task file. Unknown - key: lines, link words and ## sections are kept as written; open sessions that can’t be running are closed (see Parsed::into_task).

Source§

impl Task

Source

pub fn new(id: u32, title: String, now: DateTime<Local>) -> Self

A new todo task.

Source

pub fn log(&mut self, at: DateTime<Local>, by: Author, change: Changed)

Records change, made by someone at a time, in the activity, in time order (another computer’s clock may be behind). The latest change, when the same author made it in the same second to the same thing, takes it in (the app saves a form’s related entries one at a time), and one that ends up changing nothing goes; any other change between them keeps them apart, so the activity still says what came first.

Source

pub fn set_title( &mut self, title: String, at: DateTime<Local>, by: Author, ) -> bool

Gives the entry title, made by someone at a time, and logs it; returns whether it changed.

Source

pub fn set_tags( &mut self, tags: Vec<String>, at: DateTime<Local>, by: Author, ) -> bool

Gives the entry tags, made by someone at a time, and logs which it got and lost; returns whether they changed, the order included.

Source

pub fn set_description( &mut self, description: String, at: DateTime<Local>, by: Author, ) -> bool

Gives the entry description, made by someone at a time, and logs that it changed; returns whether it did.

Source

pub fn relate( &mut self, at: DateTime<Local>, by: Author, added: &[String], removed: &[String], )

Logs that the entry was related to the entries added names and unrelated from those removed names (see Changed::Related), by someone at a time. Whichever side keeps the link, both entries log it.

Source

pub fn set_status( &mut self, status: Status, now: DateTime<Local>, by: Author, ) -> bool

Moves the task to status and records the change, made by someone. Returns false if it already was there. Leaving doing closes the open session, so a clock never keeps running on a task that isn’t being worked on.

Source

pub fn is_running(&self) -> bool

Whether the last session is still open.

Source

pub fn running_for(&self, now: DateTime<Local>) -> Option<Duration>

How long the open session has been running, if any.

Source

pub fn start_session(&mut self, now: DateTime<Local>)

Opens a session now, unless one is already running. The caller moves the task to doing.

Source

pub fn stop_session(&mut self, now: DateTime<Local>)

Closes the open session, if any.

Source

pub fn total(&self, now: DateTime<Local>) -> Duration

Time tracked in all sessions.

Source

pub fn time_between( &self, from: DateTime<Local>, to: DateTime<Local>, now: DateTime<Local>, ) -> Duration

Time tracked inside [from, to): sessions are clipped to the range. For several tasks, see worked.

Source

pub fn started_by(&self) -> Author

Who last moved the task to doing: a person or an agent. A task in doing with no such change (from an older version, or edited by hand) counts as a person’s.

Source

pub fn status_since(&self) -> DateTime<Local>

When the status last changed (or the task was created, if never); used for sorting.

Source

pub fn asked(&self) -> Option<Asked<'_>>

The question this parked task waits on, or its answer. A question is the latest comment marked as one; a person’s comment after it answers it, as does a verdict on the decision it asked about. Starting the task after either means it was picked up, so it’s neither once the task is parked again for another reason.

Source

pub fn thread(&self) -> Vec<ThreadItem<'_>>

The comments and the activity together, oldest first, each in its own order. A change and a comment in the same second go change first: the app’s Save and tell writes the comment that tells of a change after it.

Source

pub fn is_task(&self) -> bool

Whether this entry has a status, history and sessions (only tasks do).

Source

pub fn matches(&self, query: &str) -> bool

Search: every whitespace-separated term must match. #term matches a tag prefix; anything else matches the title or a tag. Case-insensitive.

Trait Implementations§

Source§

impl Clone for Task

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Task

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Task

§

impl RefUnwindSafe for Task

§

impl Send for Task

§

impl Sync for Task

§

impl Unpin for Task

§

impl UnsafeUnpin for Task

§

impl UnwindSafe for Task

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.