pub struct Task {
pub id: String,
pub status: TaskStatus,
pub input: Message,
pub artifacts: Vec<Artifact>,
pub history: Vec<Message>,
pub error: Option<TaskError>,
pub created_at: DateTime<Utc>,
pub updated_at: Option<DateTime<Utc>>,
pub context_id: Option<String>,
}Expand description
A task in the A2A protocol
Tasks represent asynchronous operations performed by agents. They have a lifecycle from submitted to completion, with various intermediate states.
Fields§
§id: StringUnique identifier for the task
status: TaskStatusCurrent status of the task
input: MessageInput message that created this task
artifacts: Vec<Artifact>Artifacts produced by this task (replaces legacy ‘output’ field)
history: Vec<Message>Message exchange history for this task
error: Option<TaskError>Error information (present if task failed)
created_at: DateTime<Utc>When the task was created
updated_at: Option<DateTime<Utc>>When the task was last updated
context_id: Option<String>Optional context ID for grouping related tasks/messages
Implementations§
Source§impl Task
impl Task
Sourcepub fn is_terminal(&self) -> bool
pub fn is_terminal(&self) -> bool
Check if the task is in a terminal state
Sourcepub fn is_processing(&self) -> bool
pub fn is_processing(&self) -> bool
Check if the task is still processing
Sourcepub fn requires_input(&self) -> bool
pub fn requires_input(&self) -> bool
Check if the task requires input
Sourcepub fn with_status(self, status: TaskStatus) -> Self
pub fn with_status(self, status: TaskStatus) -> Self
Update the task status
Sourcepub fn with_artifact(self, artifact: Artifact) -> Self
pub fn with_artifact(self, artifact: Artifact) -> Self
Add an artifact to the task
Sourcepub fn with_history_message(self, message: Message) -> Self
pub fn with_history_message(self, message: Message) -> Self
Add a message to the history
Sourcepub fn with_error(self, error: TaskError) -> Self
pub fn with_error(self, error: TaskError) -> Self
Set the task error
Sourcepub fn with_context_id(self, context_id: impl Into<String>) -> Self
pub fn with_context_id(self, context_id: impl Into<String>) -> Self
Set the context ID
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Task
impl<'de> Deserialize<'de> for Task
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Task
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
Mutably borrows from an owned value. Read more