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
impl Task
Sourcepub fn into_task_data(self) -> TaskData
pub fn into_task_data(self) -> TaskData
Convert this Task into a TaskData.
pub fn get_taskmap(&self) -> &TaskMap
pub fn get_status(&self) -> Status
pub fn get_description(&self) -> &str
pub fn get_entry(&self) -> Option<DateTime<Utc>>
pub fn get_priority(&self) -> &str
Sourcepub fn get_wait(&self) -> Option<DateTime<Utc>>
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.
Sourcepub fn is_waiting(&self) -> bool
pub fn is_waiting(&self) -> bool
Determine whether this task is waiting now.
Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Determine whether this task is active – that is, that it has been started and not stopped.
Sourcepub fn is_blocked(&self) -> bool
pub fn is_blocked(&self) -> bool
Determine whether this task is blocked – that is, has at least one unresolved dependency.
Sourcepub fn is_blocking(&self) -> bool
pub fn is_blocking(&self) -> bool
Determine whether this task is blocking – that is, has at least one unresolved dependent.
Iterate over the task’s tags
Sourcepub fn get_annotations(&self) -> impl Iterator<Item = Annotation> + '_
pub fn get_annotations(&self) -> impl Iterator<Item = Annotation> + '_
Iterate over the task’s annotations, in arbitrary order.
Sourcepub fn get_uda(&self, namespace: &str, key: &str) -> Option<&str>
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.
Sourcepub fn get_udas(&self) -> impl Iterator<Item = ((&str, &str), &str)> + '_
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).
Sourcepub fn get_legacy_uda(&self, key: &str) -> Option<&str>
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.
Sourcepub fn get_legacy_udas(&self) -> impl Iterator<Item = (&str, &str)> + '_
pub fn get_legacy_udas(&self) -> impl Iterator<Item = (&str, &str)> + '_
Like get_udas, but returning each UDA key as a single string.
Sourcepub fn get_modified(&self) -> Option<DateTime<Utc>>
pub fn get_modified(&self) -> Option<DateTime<Utc>>
Get the modification time for this task.
Sourcepub fn get_dependencies(&self) -> impl Iterator<Item = Uuid> + '_
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.
Sourcepub fn get_value<S: Into<String>>(&self, property: S) -> Option<&str>
pub fn get_value<S: Into<String>>(&self, property: S) -> Option<&str>
Get task’s property value by name.
Sourcepub fn set_status(
&mut self,
status: Status,
ops: &mut Operations,
) -> Result<(), Error>
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.
pub fn set_description( &mut self, description: String, ops: &mut Operations, ) -> Result<(), Error>
pub fn set_priority( &mut self, priority: String, ops: &mut Operations, ) -> Result<(), Error>
pub fn set_entry( &mut self, entry: Option<DateTime<Utc>>, ops: &mut Operations, ) -> Result<(), Error>
pub fn set_wait( &mut self, wait: Option<DateTime<Utc>>, ops: &mut Operations, ) -> Result<(), Error>
pub fn set_modified( &mut self, modified: DateTime<Utc>, ops: &mut Operations, ) -> Result<(), Error>
Sourcepub fn set_value<S: Into<String>>(
&mut self,
property: S,
value: Option<String>,
ops: &mut Operations,
) -> Result<(), Error>
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.
Sourcepub fn start(&mut self, ops: &mut Operations) -> Result<(), Error>
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.
Sourcepub fn stop(&mut self, ops: &mut Operations) -> Result<(), Error>
pub fn stop(&mut self, ops: &mut Operations) -> Result<(), Error>
Stop the task by removing the start key
Sourcepub fn delete(&mut self, ops: &mut Operations) -> Result<(), Error>
👎Deprecated since 0.7.0: please call Task::set_status with Status::Deleted
pub fn delete(&mut self, ops: &mut Operations) -> Result<(), Error>
Task::set_status with Status::DeletedMark this task as deleted.
Note that this does not delete the task. It merely marks the task as deleted.
Sourcepub fn add_tag(&mut self, tag: &Tag, ops: &mut Operations) -> Result<(), Error>
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.
Sourcepub fn remove_tag(
&mut self,
tag: &Tag,
ops: &mut Operations,
) -> Result<(), Error>
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.
Sourcepub fn add_annotation(
&mut self,
ann: Annotation,
ops: &mut Operations,
) -> Result<(), Error>
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.
Sourcepub fn remove_annotation(
&mut self,
entry: DateTime<Utc>,
ops: &mut Operations,
) -> Result<(), Error>
pub fn remove_annotation( &mut self, entry: DateTime<Utc>, ops: &mut Operations, ) -> Result<(), Error>
Remove an annotation, based on its entry time.
pub fn set_due( &mut self, due: Option<DateTime<Utc>>, ops: &mut Operations, ) -> Result<(), Error>
Sourcepub fn set_uda(
&mut self,
namespace: impl AsRef<str>,
key: impl AsRef<str>,
value: impl Into<String>,
ops: &mut Operations,
) -> Result<(), Error>
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.
Sourcepub fn remove_uda(
&mut self,
namespace: impl AsRef<str>,
key: impl AsRef<str>,
ops: &mut Operations,
) -> Result<(), Error>
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.
Sourcepub fn set_legacy_uda(
&mut self,
key: impl Into<String>,
value: impl Into<String>,
ops: &mut Operations,
) -> Result<(), Error>
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.
Sourcepub fn remove_legacy_uda(
&mut self,
key: impl Into<String>,
ops: &mut Operations,
) -> Result<(), Error>
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.
Sourcepub fn add_dependency(
&mut self,
dep: Uuid,
ops: &mut Operations,
) -> Result<(), Error>
pub fn add_dependency( &mut self, dep: Uuid, ops: &mut Operations, ) -> Result<(), Error>
Add a dependency.
Sourcepub fn remove_dependency(
&mut self,
dep: Uuid,
ops: &mut Operations,
) -> Result<(), Error>
pub fn remove_dependency( &mut self, dep: Uuid, ops: &mut Operations, ) -> Result<(), Error>
Remove a dependency.
Trait Implementations§
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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