pub struct A2ATask {
pub id: String,
pub message: A2AMessage,
pub status: TaskStatus,
pub owner: Option<String>,
pub messages: Vec<A2AMessage>,
}Expand description
A unit of work in the A2A protocol.
Fields§
§id: StringUnique task identifier.
message: A2AMessageThe message that initiated this task.
Kept for single-message compatibility; the full history lives in
messages and always starts with this message.
status: TaskStatusCurrent status of the task.
owner: Option<String>Identifier of the caller/organization that created this task (P1-4).
Used for ownership authorization: tasks/get/tasks/cancel from a
different caller are rejected with a 403-style error.
messages: Vec<A2AMessage>Full message history for multi-turn dialogue (P2-2).
The first element is the initiating message (equal to message);
subsequent turns are appended by tasks/send with a taskId. The
chain is invoked over this whole history for continued tasks.
Implementations§
Source§impl A2ATask
impl A2ATask
Sourcepub fn new(id: impl Into<String>, message: A2AMessage) -> Self
pub fn new(id: impl Into<String>, message: A2AMessage) -> Self
Create a new task with Submitted status.
Sourcepub fn with_status(self, status: TaskStatus) -> Self
pub fn with_status(self, status: TaskStatus) -> Self
Set the task status.
Sourcepub fn with_owner(self, owner: impl Into<String>) -> Self
pub fn with_owner(self, owner: impl Into<String>) -> Self
Set the task owner (P1-4).
Sourcepub fn push_message(&mut self, msg: A2AMessage)
pub fn push_message(&mut self, msg: A2AMessage)
Append a message to the multi-turn history (P2-2).
Sourcepub fn message_history(&self) -> Cow<'_, [A2AMessage]>
pub fn message_history(&self) -> Cow<'_, [A2AMessage]>
The full message history for this task (P2-2).
Guaranteed to be non-empty and to start with the initiating message. Borrows the in-memory history when populated; falls back to a single-element owned history for tasks deserialized from an old single-message wire payload.