Skip to main content

lc_a2a/protocol/
message.rs

1use serde::{Deserialize, Serialize};
2
3/// A message within an A2A task.
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct A2AMessage {
6    /// Role of the message sender (e.g. "user", "agent").
7    pub role: String,
8    /// Text content of the message.
9    pub content: String,
10}
11
12impl A2AMessage {
13    /// Create a new message.
14    pub fn new(role: impl Into<String>, content: impl Into<String>) -> Self {
15        Self {
16            role: role.into(),
17            content: content.into(),
18        }
19    }
20
21    /// Create a user message.
22    pub fn user(content: impl Into<String>) -> Self {
23        Self::new("user", content)
24    }
25
26    /// Create an agent message.
27    pub fn agent(content: impl Into<String>) -> Self {
28        Self::new("agent", content)
29    }
30}