pub struct Message {
pub role: Role,
pub parts: Vec<Part>,
pub metadata: Option<Map<String, Value>>,
pub reference_task_ids: Option<Vec<String>>,
pub message_id: String,
pub task_id: Option<String>,
pub context_id: Option<String>,
pub extensions: Option<Vec<String>>,
pub kind: String,
}Expand description
A message in the A2A protocol containing parts and metadata.
Messages are the primary unit of communication in the A2A protocol. Each message has a role (user or agent), one or more content parts, and various IDs for tracking and organization.
§Example
use a2a_rs::{Message, Role, Part};
let message = Message::builder()
.role(Role::User)
.parts(vec![Part::Text {
text: "Hello, agent!".to_string(),
metadata: None,
}])
.message_id("msg-123".to_string())
.build();Fields§
§role: Role§parts: Vec<Part>§metadata: Option<Map<String, Value>>§reference_task_ids: Option<Vec<String>>§message_id: String§task_id: Option<String>§context_id: Option<String>§extensions: Option<Vec<String>>URIs of extensions relevant to this message (v0.3.0)
kind: StringImplementations§
Source§impl Message
impl Message
Sourcepub fn builder() -> MessageBuilder
pub fn builder() -> MessageBuilder
Create an instance of Message using the builder syntax
Source§impl Message
Helper methods for creating messages
impl Message
Helper methods for creating messages
Sourcepub fn user_text(text: String, message_id: String) -> Self
pub fn user_text(text: String, message_id: String) -> Self
Create a new user message with a single text part
Sourcepub fn agent_text(text: String, message_id: String) -> Self
pub fn agent_text(text: String, message_id: String) -> Self
Create a new agent message with a single text part
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
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
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
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