pub struct HandlerCore { /* private fields */ }Expand description
Shared core handling logic
Encapsulates all MCP request handling shared logic, eliminating duplication between CratesDocsHandler and
CratesDocsHandlerCore.
§Design
- Provides core methods for tool execution, list queries, etc.
- Supports optional metrics integration
- Supports configuration merging
Implementations§
Source§impl HandlerCore
impl HandlerCore
Sourcepub fn new(server: Arc<CratesDocsServer>) -> Self
pub fn new(server: Arc<CratesDocsServer>) -> Self
Sourcepub fn with_config(server: Arc<CratesDocsServer>, config: HandlerConfig) -> Self
pub fn with_config(server: Arc<CratesDocsServer>, config: HandlerConfig) -> Self
Create core handler with configuration
Sourcepub fn with_merged_config(
server: Arc<CratesDocsServer>,
base_config: HandlerConfig,
override_config: Option<HandlerConfig>,
) -> Self
pub fn with_merged_config( server: Arc<CratesDocsServer>, base_config: HandlerConfig, override_config: Option<HandlerConfig>, ) -> Self
Create core handler with merged configuration
Sourcepub fn with_metrics(self, metrics: Arc<ServerMetrics>) -> Self
pub fn with_metrics(self, metrics: Arc<ServerMetrics>) -> Self
Set metrics
Sourcepub fn server(&self) -> &Arc<CratesDocsServer>
pub fn server(&self) -> &Arc<CratesDocsServer>
Get server reference
Sourcepub fn tool_registry(&self) -> &ToolRegistry
pub fn tool_registry(&self) -> &ToolRegistry
Get tool registry
Sourcepub fn config(&self) -> &HandlerConfig
pub fn config(&self) -> &HandlerConfig
Get configuration
Sourcepub fn metrics(&self) -> Option<&Arc<ServerMetrics>>
pub fn metrics(&self) -> Option<&Arc<ServerMetrics>>
Get metrics (optional)
Sourcepub fn list_tools(&self) -> ListToolsResult
pub fn list_tools(&self) -> ListToolsResult
Get all tools list
Sourcepub fn list_resources(&self) -> ListResourcesResult
pub fn list_resources(&self) -> ListResourcesResult
Get empty resources list
Sourcepub fn list_prompts(&self) -> ListPromptsResult
pub fn list_prompts(&self) -> ListPromptsResult
Get empty prompts list
Sourcepub async fn execute_tool(
&self,
params: CallToolRequestParams,
) -> ToolExecutionResult
pub async fn execute_tool( &self, params: CallToolRequestParams, ) -> ToolExecutionResult
Execute tool call (core logic)
This method encapsulates the complete tool execution flow:
- tracing tracking
- timing statistics
- metrics recording (if enabled)
§Returns
Returns ToolExecutionResult, can be converted to different types to adapt to different traits
Auto Trait Implementations§
impl Freeze for HandlerCore
impl !RefUnwindSafe for HandlerCore
impl Send for HandlerCore
impl Sync for HandlerCore
impl Unpin for HandlerCore
impl UnsafeUnpin for HandlerCore
impl !UnwindSafe for HandlerCore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more