Skip to main content

Task

Struct Task 

Source
pub struct Task {
Show 18 fields pub id: TaskId, pub task_type: TaskType, pub title: String, pub description: String, pub status: TaskStatus, pub priority: TaskPriority, pub tags: Vec<String>, pub parent_task_id: Option<TaskId>, pub agent_id: Option<String>, pub created_by: String, pub assignee: String, pub result: Option<Value>, pub error: Option<String>, pub metadata: HashMap<String, Value>, pub created_at: DateTime<Utc>, pub updated_at: Option<DateTime<Utc>>, pub completed_at: Option<DateTime<Utc>>, pub deleted_at: Option<DateTime<Utc>>,
}
Expand description

A structured work item.

Tasks are the atomic unit of work in the agent system. They can be organized hierarchically (parent/child via parent_task_id), linked via dependencies (see TaskDependency), and tracked through lifecycle transitions.

§Example

use pe_tasks::Task;

let task = Task::new("Implement login page");
assert_eq!(task.status, pe_tasks::TaskStatus::Pending);
assert_eq!(task.priority, pe_tasks::TaskPriority::Medium);

Fields§

§id: TaskId

Unique identifier.

§task_type: TaskType

Discriminator: who/what created this task.

§title: String

Short title (what needs to be done).

§description: String

Detailed description (how/why).

§status: TaskStatus

Current status in the lifecycle.

§priority: TaskPriority

Priority level (1=urgent, 4=low).

§tags: Vec<String>

Freeform tags for classification.

§parent_task_id: Option<TaskId>

Parent task ID for subtask relationships. None = root task.

§agent_id: Option<String>

Agent that created or owns this task. None for human-created tasks.

§created_by: String

Who created this task: “user”, “system”, or an agent ID.

§assignee: String

Who is responsible: “user” or an agent ID.

§result: Option<Value>

Task output (populated on completion).

§error: Option<String>

Error message (populated on failure).

§metadata: HashMap<String, Value>

Extensible key-value metadata. Users add app-specific fields here (calendar dates, kanban columns, time tracking, etc.).

§created_at: DateTime<Utc>§updated_at: Option<DateTime<Utc>>§completed_at: Option<DateTime<Utc>>§deleted_at: Option<DateTime<Utc>>

Soft delete timestamp. None = active. Some = in trash.

Implementations§

Source§

impl Task

Source

pub fn new(title: impl Into<String>) -> Self

Create a new task with a title. Defaults: pending, medium priority, human-created.

Source

pub fn agent_task(title: impl Into<String>, agent_id: impl Into<String>) -> Self

Create an agent-owned task.

Source

pub fn plan(title: impl Into<String>) -> Self

Create a plan root task (container for subtasks).

Source

pub fn is_deleted(&self) -> bool

Whether this task has been soft-deleted.

Source

pub fn is_terminal(&self) -> bool

Whether this task is in a terminal state (completed or cancelled).

Source

pub fn with_description(self, desc: impl Into<String>) -> Self

Builder: set description.

Source

pub fn with_priority(self, priority: TaskPriority) -> Self

Builder: set priority.

Source

pub fn with_parent(self, parent_id: impl Into<TaskId>) -> Self

Builder: set parent task.

Source

pub fn with_tags(self, tags: Vec<String>) -> Self

Builder: add tags.

Trait Implementations§

Source§

impl Clone for Task

Source§

fn clone(&self) -> Task

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
Source§

impl<'de> Deserialize<'de> for Task

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Task

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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 = 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.