taskchampion

Struct Task

Source
pub struct Task { /* private fields */ }
Expand description

A task, with a high-level interface.

Building on crate::TaskData, this type implements the task model, with ergonomic APIs to manipulate tasks without deep familiarity with the task model.

Note that Task objects represent a snapshot of the task at a moment in time, and are not protected by the atomicity of the backend storage. Concurrent modifications are safe, but a Task that is cached for more than a few seconds may cause the user to see stale data. Fetch, use, and drop Tasks quickly.

See the documentation for crate::Replica for background on the ops arguments to methods on this type.

Implementations§

Source§

impl Task

Source

pub fn into_task_data(self) -> TaskData

Convert this Task into a TaskData.

Source

pub fn get_uuid(&self) -> Uuid

Get this task’s UUID.

Source

pub fn get_taskmap(&self) -> &TaskMap

👎Deprecated since 0.7.0: please use TaskData::properties
Source

pub fn get_status(&self) -> Status

Source

pub fn get_description(&self) -> &str

Source

pub fn get_entry(&self) -> Option<DateTime<Utc>>

Source

pub fn get_priority(&self) -> &str

Source

pub fn get_wait(&self) -> Option<DateTime<Utc>>

Get the wait time. If this value is set, it will be returned, even if it is in the past.

Source

pub fn is_waiting(&self) -> bool

Determine whether this task is waiting now.

Source

pub fn is_active(&self) -> bool

Determine whether this task is active – that is, that it has been started and not stopped.

Source

pub fn is_blocked(&self) -> bool

Determine whether this task is blocked – that is, has at least one unresolved dependency.

Source

pub fn is_blocking(&self) -> bool

Determine whether this task is blocking – that is, has at least one unresolved dependent.

Source

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

Check if this task has the given tag

Source

pub fn get_tags(&self) -> impl Iterator<Item = Tag> + '_

Iterate over the task’s tags

Source

pub fn get_annotations(&self) -> impl Iterator<Item = Annotation> + '_

Iterate over the task’s annotations, in arbitrary order.

Source

pub fn get_uda(&self, namespace: &str, key: &str) -> Option<&str>

Get the named user defined attributes (UDA). This will return None for any key defined in the Task data model, regardless of whether it is set or not.

Source

pub fn get_udas(&self) -> impl Iterator<Item = ((&str, &str), &str)> + '_

Get the user defined attributes (UDAs) of this task, in arbitrary order. Each key is split on the first . character. Legacy keys that do not contain . are represented as ("", key).

Source

pub fn get_legacy_uda(&self, key: &str) -> Option<&str>

Get the named user defined attribute (UDA) in a legacy format. This will return None for any key defined in the Task data model, regardless of whether it is set or not.

Source

pub fn get_legacy_udas(&self) -> impl Iterator<Item = (&str, &str)> + '_

Like get_udas, but returning each UDA key as a single string.

Source

pub fn get_modified(&self) -> Option<DateTime<Utc>>

Get the modification time for this task.

Source

pub fn get_due(&self) -> Option<DateTime<Utc>>

Get the due time for this task.

Source

pub fn get_dependencies(&self) -> impl Iterator<Item = Uuid> + '_

Get the UUIDs of tasks on which this task depends.

This includes all dependencies, regardless of their status. In fact, it may include dependencies that do not exist.

Source

pub fn get_value<S: Into<String>>(&self, property: S) -> Option<&str>

Get task’s property value by name.

Source

pub fn set_status( &mut self, status: Status, ops: &mut Operations, ) -> Result<(), Error>

Set the task’s status.

This also updates the task’s “end” property appropriately.

Source

pub fn set_description( &mut self, description: String, ops: &mut Operations, ) -> Result<(), Error>

Source

pub fn set_priority( &mut self, priority: String, ops: &mut Operations, ) -> Result<(), Error>

Source

pub fn set_entry( &mut self, entry: Option<DateTime<Utc>>, ops: &mut Operations, ) -> Result<(), Error>

Source

pub fn set_wait( &mut self, wait: Option<DateTime<Utc>>, ops: &mut Operations, ) -> Result<(), Error>

Source

pub fn set_modified( &mut self, modified: DateTime<Utc>, ops: &mut Operations, ) -> Result<(), Error>

Source

pub fn set_value<S: Into<String>>( &mut self, property: S, value: Option<String>, ops: &mut Operations, ) -> Result<(), Error>

Set a tasks’s property by name.

This will automatically update the modified timestamp if it has not already been modified, but will recognize modifications of the modified property and not make further updates to it. Use TaskData::update to modify the task without this behavior.

Source

pub fn start(&mut self, ops: &mut Operations) -> Result<(), Error>

Start the task by setting “start” to the current timestamp, if the task is not already active.

Source

pub fn stop(&mut self, ops: &mut Operations) -> Result<(), Error>

Stop the task by removing the start key

Source

pub fn done(&mut self, ops: &mut Operations) -> Result<(), Error>

Mark this task as complete

Source

pub fn delete(&mut self, ops: &mut Operations) -> Result<(), Error>

👎Deprecated since 0.7.0: please call Task::set_status with Status::Deleted

Mark this task as deleted.

Note that this does not delete the task. It merely marks the task as deleted.

Source

pub fn add_tag(&mut self, tag: &Tag, ops: &mut Operations) -> Result<(), Error>

Add a tag to this task. Does nothing if the tag is already present.

Source

pub fn remove_tag( &mut self, tag: &Tag, ops: &mut Operations, ) -> Result<(), Error>

Remove a tag from this task. Does nothing if the tag is not present.

Source

pub fn add_annotation( &mut self, ann: Annotation, ops: &mut Operations, ) -> Result<(), Error>

Add a new annotation. Note that annotations with the same entry time will overwrite one another.

Source

pub fn remove_annotation( &mut self, entry: DateTime<Utc>, ops: &mut Operations, ) -> Result<(), Error>

Remove an annotation, based on its entry time.

Source

pub fn set_due( &mut self, due: Option<DateTime<Utc>>, ops: &mut Operations, ) -> Result<(), Error>

Source

pub fn set_uda( &mut self, namespace: impl AsRef<str>, key: impl AsRef<str>, value: impl Into<String>, ops: &mut Operations, ) -> Result<(), Error>

Set a user-defined attribute (UDA). This will fail if the key is defined by the data model.

Source

pub fn remove_uda( &mut self, namespace: impl AsRef<str>, key: impl AsRef<str>, ops: &mut Operations, ) -> Result<(), Error>

Remove a user-defined attribute (UDA). This will fail if the key is defined by the data model.

Source

pub fn set_legacy_uda( &mut self, key: impl Into<String>, value: impl Into<String>, ops: &mut Operations, ) -> Result<(), Error>

Set a user-defined attribute (UDA), where the key is a legacy key.

Source

pub fn remove_legacy_uda( &mut self, key: impl Into<String>, ops: &mut Operations, ) -> Result<(), Error>

Remove a user-defined attribute (UDA), where the key is a legacy key.

Source

pub fn add_dependency( &mut self, dep: Uuid, ops: &mut Operations, ) -> Result<(), Error>

Add a dependency.

Source

pub fn remove_dependency( &mut self, dep: Uuid, ops: &mut Operations, ) -> Result<(), Error>

Remove a dependency.

Trait Implementations§

Source§

impl Clone for Task

Source§

fn clone(&self) -> Task

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 Task

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Task

Source§

fn eq(&self, other: &Task) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

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> 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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = 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<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