pub trait MessageHandler: Send + Sync {
// Required methods
fn handle_message<'life0, 'async_trait>(
&'life0 self,
message: Message,
auth: Option<AuthContext>,
) -> Pin<Box<dyn Future<Output = HandlerResult<SendMessageResponse>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn agent_card(&self, base_url: &str) -> AgentCard;
// Provided methods
fn cancel_task<'life0, 'life1, 'async_trait>(
&'life0 self,
_task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = HandlerResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn supports_streaming(&self) -> bool { ... }
fn extended_agent_card<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_base_url: &'life1 str,
_auth: &'life2 AuthContext,
) -> Pin<Box<dyn Future<Output = Option<AgentCard>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
}Expand description
Trait for implementing A2A message handlers
Returns SendMessageResponse which can be either a Task or a direct Message.
Required Methods§
Sourcefn handle_message<'life0, 'async_trait>(
&'life0 self,
message: Message,
auth: Option<AuthContext>,
) -> Pin<Box<dyn Future<Output = HandlerResult<SendMessageResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle_message<'life0, 'async_trait>(
&'life0 self,
message: Message,
auth: Option<AuthContext>,
) -> Pin<Box<dyn Future<Output = HandlerResult<SendMessageResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Process an incoming A2A message and return a Task or Message
Sourcefn agent_card(&self, base_url: &str) -> AgentCard
fn agent_card(&self, base_url: &str) -> AgentCard
Return the agent card for this handler
Provided Methods§
Sourcefn cancel_task<'life0, 'life1, 'async_trait>(
&'life0 self,
_task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = HandlerResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn cancel_task<'life0, 'life1, 'async_trait>(
&'life0 self,
_task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = HandlerResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Optional: Handle task cancellation
Sourcefn supports_streaming(&self) -> bool
fn supports_streaming(&self) -> bool
Optional: Check if handler supports streaming
Sourcefn extended_agent_card<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_base_url: &'life1 str,
_auth: &'life2 AuthContext,
) -> Pin<Box<dyn Future<Output = Option<AgentCard>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn extended_agent_card<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_base_url: &'life1 str,
_auth: &'life2 AuthContext,
) -> Pin<Box<dyn Future<Output = Option<AgentCard>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Optional: Return an extended agent card for authenticated requests