Skip to content

data

A2A Protocol v1.0 Data Structures

Task: Core A2A work unit (v1.0)

Fields

FieldTypeDescription
idString
context_idString
statusTaskStatus
historyOption<Vec<Message>>
artifactsOption<Vec<Artifact>>
metadataOption<HashMap<String, serde_json::Value>>

Methods

fn new(context_id: String) -> Self
fn with_id(id: String, context_id: String) -> Self
fn update_status(&mut self, state: TaskState)
fn update_status_with_message(&mut self, state: TaskState, message: Message)
fn add_artifact(&mut self, artifact: Artifact)
fn add_to_history(&mut self, message: Message)
fn set_metadata(&mut self, key: String, value: Value)
fn is_terminal(&self) -> bool
fn is_active(&self) -> bool

Task Status: Current state with optional message.

Fields

FieldTypeDescription
stateTaskState
messageOption<Message>
timestampOption<String>

Methods

fn new(state: TaskState) -> Self
fn update_timestamp(&mut self)

Message: Core A2A communication object (v1.0)

Fields

FieldTypeDescription
roleMessageRole
partsVec<Part>
message_idString
task_idOption<String>
context_idOption<String>
metadataOption<HashMap<String, serde_json::Value>>
extensionsOption<Vec<String>>
reference_task_idsOption<Vec<String>>

Methods

fn new(role: MessageRole, parts: Vec<Part>, task_id: String) -> Self
fn with_id(message_id: String, role: MessageRole, parts: Vec<Part>) -> Self
fn text<impl Into<String>>(role: MessageRole, text: impl Into, task_id: String) -> Self
fn status<impl Into<String>>(text: impl Into, task_id: String) -> Self
fn error<impl Into<String>>(text: impl Into, task_id: String) -> Self
fn add_part(&mut self, part: Part)
fn set_metadata(&mut self, key: String, value: Value)
fn with_context(self, context_id: String) -> Self
fn add_extension(&mut self, extension: String)
fn get_text_content(&self) -> String
fn is_text_only(&self) -> bool
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

FieldTypeDescription
textOption&lt;String&gt;
rawOption&lt;String&gt;
urlOption&lt;String&gt;
dataOption&lt;serde_json::Value&gt;
metadataOption&lt;HashMap&lt;String, serde_json::Value&gt;&gt;
filenameOption&lt;String&gt;
media_typeOption&lt;String&gt;

Methods

fn text<impl Into<String>>(text: impl Into) -> Self

Text-only part.

fn data(value: Value) -> Self

Structured data part.

fn url<impl Into<String>>(uri: impl Into) -> Self

URL reference part.

fn raw<impl Into<String>>(base64: impl Into) -> Self

Base64-encoded raw bytes part.

fn url_with_media<impl Into<String>, impl Into<String>>(uri: impl Into, media_type: impl Into) -> Self

URL part with media type annotation.

fn is_text(&self) -> bool

Check which content variant is populated.

fn is_data(&self) -> bool
fn is_url(&self) -> bool
fn is_raw(&self) -> bool
fn get_text(&self) -> Option<&str>

Extract text content (if present).

Artifact: Agent output (v1.0 shape)

Fields

FieldTypeDescription
artifact_idString
nameOption&lt;String&gt;
descriptionOption&lt;String&gt;
partsVec&lt;Part&gt;
metadataOption&lt;HashMap&lt;String, serde_json::Value&gt;&gt;
extensionsOption&lt;Vec&lt;String&gt;&gt;

Methods

fn new(parts: Vec<Part>) -> Self

Create an artifact with a generated ID.

fn text<impl Into<String>>(text: impl Into) -> Self

Create a simple text artifact.

fn data(value: Value) -> Self

Create a data artifact.

fn with_name<impl Into<String>>(self, name: impl Into) -> Self

Builder: set name.

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

Builder: set description.

fn with_id<impl Into<String>>(self, id: impl Into) -> Self

Builder: set artifact_id explicitly.

fn set_metadata(&mut self, key: String, value: Value)
fn get_text_content(&self) -> Option<&str>

Extract text from the first text part (convenience).

fn get_data_content(&self) -> Option<&Value>

Extract data from the first data part (convenience).

Authentication information for push notification delivery.

Fields

FieldTypeDescription
schemeString
credentialsString

Per-task push notification configuration (v1.0).

Fields

FieldTypeDescription
tenantOption&lt;String&gt;
idString
task_idString
urlString
tokenOption&lt;String&gt;
authenticationOption&lt;AuthenticationInfo&gt;

Methods

fn new<impl Into<String>, impl Into<String>, impl Into<String>>(id: impl Into, task_id: impl Into, url: impl Into) -> Self
fn with_tenant<impl Into<String>>(self, tenant: impl Into) -> Self
fn with_token<impl Into<String>>(self, token: impl Into) -> Self
fn with_authentication(self, auth: AuthenticationInfo) -> Self

Task State: A2A v1.0 SCREAMING_SNAKE enum.

Variants

VariantDescription
Unspecified
Submitted
Working
InputRequired
Completed
Failed
Canceled
Rejected
AuthRequired

Methods

fn is_terminal(&self) -> bool

Returns true for terminal states: Completed, Failed, Canceled, Rejected.

fn is_active(&self) -> bool

Returns true for active states: Submitted, Working, InputRequired.

fn as_str(&self) -> &''static str

Lowercase string for logging/display (not wire format).

Message Role (v1.0 — SCREAMING_SNAKE serialization)

Variants

VariantDescription
Unspecified
User
Agent