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: TaskIdUnique identifier.
task_type: TaskTypeDiscriminator: who/what created this task.
title: StringShort title (what needs to be done).
description: StringDetailed description (how/why).
status: TaskStatusCurrent status in the lifecycle.
priority: TaskPriorityPriority level (1=urgent, 4=low).
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: StringWho created this task: “user”, “system”, or an agent ID.
assignee: StringWho 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
impl Task
Sourcepub fn new(title: impl Into<String>) -> Self
pub fn new(title: impl Into<String>) -> Self
Create a new task with a title. Defaults: pending, medium priority, human-created.
Sourcepub fn agent_task(title: impl Into<String>, agent_id: impl Into<String>) -> Self
pub fn agent_task(title: impl Into<String>, agent_id: impl Into<String>) -> Self
Create an agent-owned task.
Sourcepub fn plan(title: impl Into<String>) -> Self
pub fn plan(title: impl Into<String>) -> Self
Create a plan root task (container for subtasks).
Sourcepub fn is_deleted(&self) -> bool
pub fn is_deleted(&self) -> bool
Whether this task has been soft-deleted.
Sourcepub fn is_terminal(&self) -> bool
pub fn is_terminal(&self) -> bool
Whether this task is in a terminal state (completed or cancelled).
Sourcepub fn with_description(self, desc: impl Into<String>) -> Self
pub fn with_description(self, desc: impl Into<String>) -> Self
Builder: set description.
Sourcepub fn with_priority(self, priority: TaskPriority) -> Self
pub fn with_priority(self, priority: TaskPriority) -> Self
Builder: set priority.
Sourcepub fn with_parent(self, parent_id: impl Into<TaskId>) -> Self
pub fn with_parent(self, parent_id: impl Into<TaskId>) -> Self
Builder: set parent task.
Builder: add tags.