pub trait A2aHandler:
Send
+ Sync
+ 'static {
// Required methods
fn agent_card(&self) -> &AgentCard;
fn on_send_message<'life0, 'async_trait>(
&'life0 self,
req: SendMessageRequest,
) -> Pin<Box<dyn Future<Output = Result<SendMessageResponse, A2aError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn on_send_streaming_message<'life0, 'async_trait>(
&'life0 self,
req: SendMessageRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamResponse, A2aError>> + Send>>, A2aError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn on_get_task<'life0, 'async_trait>(
&'life0 self,
req: GetTaskRequest,
) -> Pin<Box<dyn Future<Output = Result<Task, A2aError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn on_list_tasks<'life0, 'async_trait>(
&'life0 self,
req: ListTasksRequest,
) -> Pin<Box<dyn Future<Output = Result<ListTasksResponse, A2aError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn on_cancel_task<'life0, 'async_trait>(
&'life0 self,
req: CancelTaskRequest,
) -> Pin<Box<dyn Future<Output = Result<Task, A2aError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn on_subscribe_to_task<'life0, 'async_trait>(
&'life0 self,
req: SubscribeToTaskRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamResponse, A2aError>> + Send>>, A2aError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn on_create_push_config<'life0, 'async_trait>(
&'life0 self,
_config: TaskPushNotificationConfig,
) -> Pin<Box<dyn Future<Output = Result<TaskPushNotificationConfig, A2aError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn on_get_push_config<'life0, 'async_trait>(
&'life0 self,
_req: GetTaskPushNotificationConfigRequest,
) -> Pin<Box<dyn Future<Output = Result<TaskPushNotificationConfig, A2aError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn on_list_push_configs<'life0, 'async_trait>(
&'life0 self,
_req: ListTaskPushNotificationConfigsRequest,
) -> Pin<Box<dyn Future<Output = Result<ListTaskPushNotificationConfigsResponse, A2aError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn on_delete_push_config<'life0, 'async_trait>(
&'life0 self,
_req: DeleteTaskPushNotificationConfigRequest,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn on_get_extended_agent_card<'life0, 'async_trait>(
&'life0 self,
_req: GetExtendedAgentCardRequest,
) -> Pin<Box<dyn Future<Output = Result<AgentCard, A2aError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Core handler trait for A2A agents.
Implement this trait to define agent behavior. The server infrastructure will route requests from JSON-RPC, REST, and gRPC to these methods.
Required Methods§
Sourcefn agent_card(&self) -> &AgentCard
fn agent_card(&self) -> &AgentCard
Return the agent card for discovery.
Sourcefn on_send_message<'life0, 'async_trait>(
&'life0 self,
req: SendMessageRequest,
) -> Pin<Box<dyn Future<Output = Result<SendMessageResponse, A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_send_message<'life0, 'async_trait>(
&'life0 self,
req: SendMessageRequest,
) -> Pin<Box<dyn Future<Output = Result<SendMessageResponse, A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handle a message/send request.
Sourcefn on_send_streaming_message<'life0, 'async_trait>(
&'life0 self,
req: SendMessageRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamResponse, A2aError>> + Send>>, A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_send_streaming_message<'life0, 'async_trait>(
&'life0 self,
req: SendMessageRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamResponse, A2aError>> + Send>>, A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handle a message/stream request (server-streaming).
Sourcefn on_get_task<'life0, 'async_trait>(
&'life0 self,
req: GetTaskRequest,
) -> Pin<Box<dyn Future<Output = Result<Task, A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_get_task<'life0, 'async_trait>(
&'life0 self,
req: GetTaskRequest,
) -> Pin<Box<dyn Future<Output = Result<Task, A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handle a tasks/get request.
Sourcefn on_list_tasks<'life0, 'async_trait>(
&'life0 self,
req: ListTasksRequest,
) -> Pin<Box<dyn Future<Output = Result<ListTasksResponse, A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_list_tasks<'life0, 'async_trait>(
&'life0 self,
req: ListTasksRequest,
) -> Pin<Box<dyn Future<Output = Result<ListTasksResponse, A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handle a tasks/list request.
Sourcefn on_cancel_task<'life0, 'async_trait>(
&'life0 self,
req: CancelTaskRequest,
) -> Pin<Box<dyn Future<Output = Result<Task, A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_cancel_task<'life0, 'async_trait>(
&'life0 self,
req: CancelTaskRequest,
) -> Pin<Box<dyn Future<Output = Result<Task, A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handle a tasks/cancel request.
Sourcefn on_subscribe_to_task<'life0, 'async_trait>(
&'life0 self,
req: SubscribeToTaskRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamResponse, A2aError>> + Send>>, A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_subscribe_to_task<'life0, 'async_trait>(
&'life0 self,
req: SubscribeToTaskRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamResponse, A2aError>> + Send>>, A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handle a tasks/resubscribe request (server-streaming).
Provided Methods§
Sourcefn on_create_push_config<'life0, 'async_trait>(
&'life0 self,
_config: TaskPushNotificationConfig,
) -> Pin<Box<dyn Future<Output = Result<TaskPushNotificationConfig, A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_create_push_config<'life0, 'async_trait>(
&'life0 self,
_config: TaskPushNotificationConfig,
) -> Pin<Box<dyn Future<Output = Result<TaskPushNotificationConfig, A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Create a push notification config. Default returns unsupported.
Sourcefn on_get_push_config<'life0, 'async_trait>(
&'life0 self,
_req: GetTaskPushNotificationConfigRequest,
) -> Pin<Box<dyn Future<Output = Result<TaskPushNotificationConfig, A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_get_push_config<'life0, 'async_trait>(
&'life0 self,
_req: GetTaskPushNotificationConfigRequest,
) -> Pin<Box<dyn Future<Output = Result<TaskPushNotificationConfig, A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a push notification config. Default returns unsupported.
Sourcefn on_list_push_configs<'life0, 'async_trait>(
&'life0 self,
_req: ListTaskPushNotificationConfigsRequest,
) -> Pin<Box<dyn Future<Output = Result<ListTaskPushNotificationConfigsResponse, A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_list_push_configs<'life0, 'async_trait>(
&'life0 self,
_req: ListTaskPushNotificationConfigsRequest,
) -> Pin<Box<dyn Future<Output = Result<ListTaskPushNotificationConfigsResponse, A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
List push notification configs. Default returns unsupported.
Sourcefn on_delete_push_config<'life0, 'async_trait>(
&'life0 self,
_req: DeleteTaskPushNotificationConfigRequest,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_delete_push_config<'life0, 'async_trait>(
&'life0 self,
_req: DeleteTaskPushNotificationConfigRequest,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Delete a push notification config. Default returns unsupported.
Sourcefn on_get_extended_agent_card<'life0, 'async_trait>(
&'life0 self,
_req: GetExtendedAgentCardRequest,
) -> Pin<Box<dyn Future<Output = Result<AgentCard, A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_get_extended_agent_card<'life0, 'async_trait>(
&'life0 self,
_req: GetExtendedAgentCardRequest,
) -> Pin<Box<dyn Future<Output = Result<AgentCard, A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the authenticated extended agent card. Default returns not configured.