Skip to main content

MessageHandler

Trait MessageHandler 

Source
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§

Source

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

Source

fn agent_card(&self, base_url: &str) -> AgentCard

Return the agent card for this handler

Provided Methods§

Source

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

Source

fn supports_streaming(&self) -> bool

Optional: Check if handler supports streaming

Source

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

Implementors§