pub struct Message {
pub role: Role,
pub parts: Vec<Part>,
pub message_id: Option<String>,
pub task_id: Option<String>,
pub context_id: Option<String>,
pub metadata: Option<Value>,
}Expand description
A single message in the A2A conversation, consisting of one or more Parts.
Messages carry content between the caller and the agent. Use Message::user_text
to construct a simple single-part text message from the user side.
§Examples
use zeph_a2a::{Message, Part, Role};
let msg = Message::user_text("Summarize this document.");
assert_eq!(msg.role, Role::User);
assert_eq!(msg.text_content(), Some("Summarize this document."));Fields§
§role: RoleWho sent this message.
parts: Vec<Part>Content parts; at least one is expected for meaningful messages.
message_id: Option<String>Optional stable identifier for this specific message.
task_id: Option<String>Task this message belongs to (set by the server on responses).
context_id: Option<String>Conversation context shared with other tasks in the same session.
metadata: Option<Value>Arbitrary extension metadata.
Implementations§
Source§impl Message
impl Message
Sourcepub fn user_text(s: impl Into<String>) -> Self
pub fn user_text(s: impl Into<String>) -> Self
Construct a single-part user text message.
This is the most common way to build an outgoing message when calling a peer agent.
§Examples
use zeph_a2a::{Message, Role};
let msg = Message::user_text("Please summarize this.");
assert_eq!(msg.role, Role::User);
assert_eq!(msg.text_content(), Some("Please summarize this."));Sourcepub fn text_content(&self) -> Option<&str>
pub fn text_content(&self) -> Option<&str>
Return the text of the first Part::Text in this message, if any.
For messages that may contain multiple text parts, prefer all_text_content.
§Examples
use zeph_a2a::Message;
let msg = Message::user_text("hello");
assert_eq!(msg.text_content(), Some("hello"));Sourcepub fn all_text_content(&self) -> String
pub fn all_text_content(&self) -> String
Collect and concatenate all Part::Text entries in order.
Unlike text_content which returns only the first text part, this method
preserves the full message when an agent sends multiple text parts.
Returns an empty string if the message contains no text parts.