pub trait McpHandler: Send + Sync {
// Required methods
fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 McpRequest,
) -> Pin<Box<dyn Future<Output = Result<McpResponse>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn handle_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
notification: &'life1 McpNotification,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
MCP 消息处理器 trait
Required Methods§
Sourcefn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 McpRequest,
) -> Pin<Box<dyn Future<Output = Result<McpResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 McpRequest,
) -> Pin<Box<dyn Future<Output = Result<McpResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
处理请求
Sourcefn handle_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
notification: &'life1 McpNotification,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
notification: &'life1 McpNotification,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
处理通知
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".