pub trait ClientHandlerCore:
Send
+ Sync
+ 'static {
// Required methods
fn handle_request<'life0, 'life1, 'async_trait>(
&'life0 self,
request: RequestFromServer,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<ResultFromClient, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn handle_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
notification: NotificationFromServer,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn handle_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
error: &'life1 RpcError,
runtime: &'life2 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided method
fn handle_process_error<'life0, 'life1, 'async_trait>(
&'life0 self,
error_message: String,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Defines the ClientHandlerCore trait for handling Model Context Protocol (MCP) client operations.
Unlike ClientHandler, this trait offers no default implementations, providing full control over MCP message handling
while ensures type-safe processing of the messages through three distinct handlers for requests, notifications, and errors.
Required Methods§
Sourcefn handle_request<'life0, 'life1, 'async_trait>(
&'life0 self,
request: RequestFromServer,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<ResultFromClient, RpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle_request<'life0, 'life1, 'async_trait>(
&'life0 self,
request: RequestFromServer,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<ResultFromClient, RpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn handle_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
notification: NotificationFromServer,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
notification: NotificationFromServer,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Asynchronously handles an incoming notification from the server.
§Parameters
notification– The notification data received from the MCP server.
Sourcefn handle_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
error: &'life1 RpcError,
runtime: &'life2 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
error: &'life1 RpcError,
runtime: &'life2 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Asynchronously handles an error received from the server.
§Parameters
error– The error data received from the MCP server.