data
A2A Protocol v1.0 Data Structures
Structs
Section titled “Structs”Task: Core A2A work unit (v1.0)
Fields
| Field | Type | Description |
|---|---|---|
id | String | |
context_id | String | |
status | TaskStatus | |
history | Option<Vec<Message>> | |
artifacts | Option<Vec<Artifact>> | |
metadata | Option<HashMap<String, serde_json::Value>> |
Methods
fn new(context_id: String) -> Selfwith_id
Section titled “with_id”fn with_id(id: String, context_id: String) -> Selfupdate_status
Section titled “update_status”fn update_status(&mut self, state: TaskState)update_status_with_message
Section titled “update_status_with_message”fn update_status_with_message(&mut self, state: TaskState, message: Message)add_artifact
Section titled “add_artifact”fn add_artifact(&mut self, artifact: Artifact)add_to_history
Section titled “add_to_history”fn add_to_history(&mut self, message: Message)set_metadata
Section titled “set_metadata”fn set_metadata(&mut self, key: String, value: Value)is_terminal
Section titled “is_terminal”fn is_terminal(&self) -> boolis_active
Section titled “is_active”fn is_active(&self) -> boolTaskStatus
Section titled “TaskStatus”Task Status: Current state with optional message.
Fields
| Field | Type | Description |
|---|---|---|
state | TaskState | |
message | Option<Message> | |
timestamp | Option<String> |
Methods
fn new(state: TaskState) -> Selfupdate_timestamp
Section titled “update_timestamp”fn update_timestamp(&mut self)Message
Section titled “Message”Message: Core A2A communication object (v1.0)
Fields
| Field | Type | Description |
|---|---|---|
role | MessageRole | |
parts | Vec<Part> | |
message_id | String | |
task_id | Option<String> | |
context_id | Option<String> | |
metadata | Option<HashMap<String, serde_json::Value>> | |
extensions | Option<Vec<String>> | |
reference_task_ids | Option<Vec<String>> |
Methods
fn new(role: MessageRole, parts: Vec<Part>, task_id: String) -> Selfwith_id
Section titled “with_id”fn with_id(message_id: String, role: MessageRole, parts: Vec<Part>) -> Selffn text<impl Into<String>>(role: MessageRole, text: impl Into, task_id: String) -> Selfstatus
Section titled “status”fn status<impl Into<String>>(text: impl Into, task_id: String) -> Selffn error<impl Into<String>>(text: impl Into, task_id: String) -> Selfadd_part
Section titled “add_part”fn add_part(&mut self, part: Part)set_metadata
Section titled “set_metadata”fn set_metadata(&mut self, key: String, value: Value)with_context
Section titled “with_context”fn with_context(self, context_id: String) -> Selfadd_extension
Section titled “add_extension”fn add_extension(&mut self, extension: String)get_text_content
Section titled “get_text_content”fn get_text_content(&self) -> Stringis_text_only
Section titled “is_text_only”fn is_text_only(&self) -> boolget_data_parts
Section titled “get_data_parts”fn get_data_parts(&self) -> Vec<&Part>Part: Flat multi-modal content container (v1.0)
A Part carries exactly one of: text, raw (base64), url, or structured data. Additional fields (filename, media_type, metadata) annotate the content.
Fields
| Field | Type | Description |
|---|---|---|
text | Option<String> | |
raw | Option<String> | |
url | Option<String> | |
data | Option<serde_json::Value> | |
metadata | Option<HashMap<String, serde_json::Value>> | |
filename | Option<String> | |
media_type | Option<String> |
Methods
fn text<impl Into<String>>(text: impl Into) -> SelfText-only part.
fn data(value: Value) -> SelfStructured data part.
fn url<impl Into<String>>(uri: impl Into) -> SelfURL reference part.
fn raw<impl Into<String>>(base64: impl Into) -> SelfBase64-encoded raw bytes part.
url_with_media
Section titled “url_with_media”fn url_with_media<impl Into<String>, impl Into<String>>(uri: impl Into, media_type: impl Into) -> SelfURL part with media type annotation.
is_text
Section titled “is_text”fn is_text(&self) -> boolCheck which content variant is populated.
is_data
Section titled “is_data”fn is_data(&self) -> boolis_url
Section titled “is_url”fn is_url(&self) -> boolis_raw
Section titled “is_raw”fn is_raw(&self) -> boolget_text
Section titled “get_text”fn get_text(&self) -> Option<&str>Extract text content (if present).
Artifact
Section titled “Artifact”Artifact: Agent output (v1.0 shape)
Fields
| Field | Type | Description |
|---|---|---|
artifact_id | String | |
name | Option<String> | |
description | Option<String> | |
parts | Vec<Part> | |
metadata | Option<HashMap<String, serde_json::Value>> | |
extensions | Option<Vec<String>> |
Methods
fn new(parts: Vec<Part>) -> SelfCreate an artifact with a generated ID.
fn text<impl Into<String>>(text: impl Into) -> SelfCreate a simple text artifact.
fn data(value: Value) -> SelfCreate a data artifact.
with_name
Section titled “with_name”fn with_name<impl Into<String>>(self, name: impl Into) -> SelfBuilder: set name.
with_description
Section titled “with_description”fn with_description<impl Into<String>>(self, description: impl Into) -> SelfBuilder: set description.
with_id
Section titled “with_id”fn with_id<impl Into<String>>(self, id: impl Into) -> SelfBuilder: set artifact_id explicitly.
set_metadata
Section titled “set_metadata”fn set_metadata(&mut self, key: String, value: Value)get_text_content
Section titled “get_text_content”fn get_text_content(&self) -> Option<&str>Extract text from the first text part (convenience).
get_data_content
Section titled “get_data_content”fn get_data_content(&self) -> Option<&Value>Extract data from the first data part (convenience).
AuthenticationInfo
Section titled “AuthenticationInfo”Authentication information for push notification delivery.
Fields
| Field | Type | Description |
|---|---|---|
scheme | String | |
credentials | String |
TaskPushNotificationConfig
Section titled “TaskPushNotificationConfig”Per-task push notification configuration (v1.0).
Fields
| Field | Type | Description |
|---|---|---|
tenant | Option<String> | |
id | String | |
task_id | String | |
url | String | |
token | Option<String> | |
authentication | Option<AuthenticationInfo> |
Methods
fn new<impl Into<String>, impl Into<String>, impl Into<String>>(id: impl Into, task_id: impl Into, url: impl Into) -> Selfwith_tenant
Section titled “with_tenant”fn with_tenant<impl Into<String>>(self, tenant: impl Into) -> Selfwith_token
Section titled “with_token”fn with_token<impl Into<String>>(self, token: impl Into) -> Selfwith_authentication
Section titled “with_authentication”fn with_authentication(self, auth: AuthenticationInfo) -> SelfTaskState
Section titled “TaskState”Task State: A2A v1.0 SCREAMING_SNAKE enum.
Variants
| Variant | Description |
|---|---|
Unspecified | |
Submitted | |
Working | |
InputRequired | |
Completed | |
Failed | |
Canceled | |
Rejected | |
AuthRequired |
Methods
is_terminal
Section titled “is_terminal”fn is_terminal(&self) -> boolReturns true for terminal states: Completed, Failed, Canceled, Rejected.
is_active
Section titled “is_active”fn is_active(&self) -> boolReturns true for active states: Submitted, Working, InputRequired.
as_str
Section titled “as_str”fn as_str(&self) -> &''static strLowercase string for logging/display (not wire format).
MessageRole
Section titled “MessageRole”Message Role (v1.0 — SCREAMING_SNAKE serialization)
Variants
| Variant | Description |
|---|---|
Unspecified | |
User | |
Agent |