Struct task_hookrs::task::Task

source ·
pub struct Task { /* private fields */ }
Expand description

Task type

A task must have four things:

  • A Status
  • An UUID
  • An Entry-Date
  • A Description

all other Data is optional by taskwarrior. This type is a simple rust representation of the JSON exported by taskwarrior.

For further explanations of the fields please consult the documentation on https://taskwarrior.org/

It is deserializeable and serializeable via serde_json, so importing and exporting taskwarrior tasks is simply serializing and deserializing objects of this type.

Implementations§

Create a new Task instance

Examples found in repository?
src/task.rs (lines 789-813)
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
    fn visit_map<V>(self, mut visitor: V) -> RResult<Task, V::Error>
    where
        V: MapAccess<'de>,
    {
        let mut id = None;

        let mut status = None;
        let mut uuid = None;
        let mut entry = None;
        let mut description = None;

        let mut annotations = None;
        let mut depends = None;
        let mut due = None;
        let mut end = None;
        let mut imask = None;
        let mut mask = None;
        let mut modified = None;
        let mut parent = None;
        let mut priority = None;
        let mut project = None;
        let mut recur = None;
        let mut scheduled = None;
        let mut start = None;
        let mut tags = None;
        let mut until = None;
        let mut wait = None;
        let mut urgency = None;
        let mut uda = UDA::default();

        loop {
            let key: Option<String> = visitor.next_key()?;
            if key.is_none() {
                break;
            }
            let key = key.unwrap();

            match &key[..] {
                "id" => {
                    id = Some(visitor.next_value()?);
                }

                "status" => {
                    status = Some(visitor.next_value()?);
                }
                "uuid" => {
                    uuid = Some(visitor.next_value()?);
                }
                "entry" => {
                    entry = Some(visitor.next_value()?);
                }
                "description" => {
                    description = Some(visitor.next_value()?);
                }

                "annotations" => {
                    annotations = Some(visitor.next_value()?);
                }
                "depends" => {
                    let raw: String = visitor.next_value()?;
                    let mut uuids = vec![];
                    for uuid in raw.split(',') {
                        uuids.push(Uuid::parse_str(uuid).map_err(V::Error::custom)?);
                    }
                    depends = Some(uuids);
                }
                "due" => {
                    due = Some(visitor.next_value()?);
                }
                "end" => {
                    end = Some(visitor.next_value()?);
                }
                "imask" => {
                    imask = Some(visitor.next_value()?);
                }
                "mask" => {
                    mask = Some(visitor.next_value()?);
                }
                "modified" => {
                    modified = Some(visitor.next_value()?);
                }
                "parent" => {
                    parent = Some(visitor.next_value()?);
                }
                "priority" => {
                    priority = Some(visitor.next_value()?);
                }
                "project" => {
                    project = Some(visitor.next_value()?);
                }
                "recur" => {
                    recur = Some(visitor.next_value()?);
                }
                "scheduled" => {
                    scheduled = Some(visitor.next_value()?);
                }
                "start" => {
                    start = Some(visitor.next_value()?);
                }
                "tags" => {
                    tags = Some(visitor.next_value()?);
                }
                "until" => {
                    until = Some(visitor.next_value()?);
                }
                "wait" => {
                    wait = Some(visitor.next_value()?);
                }
                "urgency" => {
                    urgency = Some(visitor.next_value()?);
                }

                field => {
                    log::debug!("Inserting '{}' as UDA", field);
                    let uda_value: UDAValue = visitor.next_value()?;
                    uda.insert(UDAName::from(field), uda_value);
                }
            }
        }

        let status = status.ok_or_else(|| V::Error::missing_field("status"))?;
        let uuid = uuid.ok_or_else(|| V::Error::missing_field("uuid"))?;
        let entry = entry.ok_or_else(|| V::Error::missing_field("entry"))?;
        let description = description.ok_or_else(|| V::Error::missing_field("description"))?;

        let task = Task::new(
            id,
            status,
            uuid,
            entry,
            description,
            annotations,
            depends,
            due,
            end,
            imask,
            mask,
            modified,
            parent,
            priority,
            project,
            recur,
            scheduled,
            start,
            tags,
            until,
            wait,
            urgency,
            uda,
        );

        Ok(task)
    }

Get the id of the task

Get the status of the task

Get the status of the task mutable

Get the uuid of the task

Get the uuid of the task mutable

Get the entry date of the task

Get the entry date of the task mutable

Get the description of the task

Get the description of the task mutable

Get the annotations of the task

Get the annotations of the task mutable

Set annotations

Get the dependencies of the task

Get the dependencies of the task mutable

Set depends

Get the due date of the task

Get the due date of the task mutable

Set due

Get the end date of the task

Get the end date of the task mutable

Set end

Get the imask of the task

Get the imask of the task mutable

Set imask

Get the mask of the task

Get the mask of the task mutable

Set mask

Get the modified date of the task

Get the modified date of the task mutable

Set modified

Get the parent of the task

Get the parent of the task mutable

Set parent

Get the priority of the task

Get the priority of the task mutable

Set priority

Get the project of the task

Get the project of the task mutable

Set project

Get the recur of the task

This is exported as String by now. This might change in future versions of this crate.

This is exported as String by now. This might change in future versions of this crate. mutable

Set recur

Get the scheduled date of the task

Get the scheduled date of the task mutable

Set scheduled

Get the start date of the task

Get the start date of the task mutable

Set start

Get the tags of the task

Get the tags of the task mutable

Set tags

Get the until date of the task

Get the until date of the task mutable

Set until

Get the urgency of the task

Get the urgency of the task

Set the urgency of the task

Get the wait date of the task

Get the wait date of the task mutable

Set wait

Get the BTreeMap that contains the UDA

Examples found in repository?
src/task.rs (line 612)
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
    fn serialize<S>(&self, serializer: S) -> RResult<S::Ok, S::Error>
    where
        S: Serializer,
    {
        let mut state = serializer.serialize_map(None)?;
        state.serialize_entry("status", &self.status)?;
        state.serialize_entry("uuid", &self.uuid)?;
        state.serialize_entry("entry", &self.entry)?;
        state.serialize_entry("description", &self.description)?;

        self.annotations
            .as_ref()
            .map(|v| state.serialize_entry("annotations", v));
        self.tags.as_ref().map(|v| state.serialize_entry("tags", v));
        self.id.as_ref().map(|v| state.serialize_entry("id", v));
        self.recur
            .as_ref()
            .map(|ref v| state.serialize_entry("recur", v));
        self.depends.as_ref().map(|v| {
            let v: Vec<String> = v.iter().map(Uuid::to_string).collect();
            state.serialize_entry("depends", &v.join(","))
        });
        self.due
            .as_ref()
            .map(|ref v| state.serialize_entry("due", v));
        self.end
            .as_ref()
            .map(|ref v| state.serialize_entry("end", v));
        self.imask
            .as_ref()
            .map(|ref v| state.serialize_entry("imask", v));
        self.mask
            .as_ref()
            .map(|ref v| state.serialize_entry("mask", v));
        self.modified
            .as_ref()
            .map(|ref v| state.serialize_entry("modified", v));
        self.parent
            .as_ref()
            .map(|ref v| state.serialize_entry("parent", v));
        self.priority
            .as_ref()
            .map(|ref v| state.serialize_entry("priority", v));
        self.project
            .as_ref()
            .map(|ref v| state.serialize_entry("project", v));
        self.scheduled
            .as_ref()
            .map(|ref v| state.serialize_entry("scheduled", v));
        self.start
            .as_ref()
            .map(|ref v| state.serialize_entry("start", v));
        self.until
            .as_ref()
            .map(|ref v| state.serialize_entry("until", v));
        self.wait
            .as_ref()
            .map(|ref v| state.serialize_entry("wait", v));
        self.urgency
            .as_ref()
            .map(|ref v| state.serialize_entry("urgency", v));

        for (key, value) in self.uda().iter() {
            state.serialize_entry(key, value)?;
        }

        state.end()
    }

Get the BTreeMap that contains the UDA mutable

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.