pub struct Message {
pub role: Role,
pub parts: Vec<MessagePart>,
pub message_id: Option<String>,
pub task_id: Option<String>,
pub context_id: Option<String>,
pub metadata: Option<HashMap<String, Value>>,
pub extensions: Option<HashMap<String, Value>>,
}Expand description
A message in the A2A protocol
Messages are the primary unit of communication between agents. Each message has a role (user or assistant), one or more parts (text, file, or data), and optional metadata and extensions.
Fields§
§role: RoleRole of the message sender
parts: Vec<MessagePart>Message content parts (at least one required)
message_id: Option<String>Optional message identifier
task_id: Option<String>Optional task identifier (for associating message with a task)
context_id: Option<String>Optional context identifier (for multi-turn conversations)
metadata: Option<HashMap<String, Value>>Optional metadata for the message
extensions: Option<HashMap<String, Value>>Optional extensions indicating additional protocol features
Implementations§
Source§impl Message
impl Message
Sourcepub fn assistant(text: impl Into<String>) -> Self
pub fn assistant(text: impl Into<String>) -> Self
Create an assistant message with text content
Sourcepub fn builder() -> MessageBuilder
pub fn builder() -> MessageBuilder
Create a new message builder
Sourcepub fn with_metadata(self, key: impl Into<String>, value: Value) -> Self
pub fn with_metadata(self, key: impl Into<String>, value: Value) -> Self
Add a metadata field to the message
Sourcepub fn with_extension(self, key: impl Into<String>, value: Value) -> Self
pub fn with_extension(self, key: impl Into<String>, value: Value) -> Self
Add an extension to the message
Sourcepub fn with_part(self, part: MessagePart) -> Self
pub fn with_part(self, part: MessagePart) -> Self
Add a message 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
impl StructuralPartialEq for Message
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin 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