snm_brightdata_client/
rpc_client.rs

1// src/rpc_client.rs - Cleaned up to use ToolResolver
2use crate::error::BrightDataError;
3use crate::tool::ToolResolver;
4use serde_json::Value;
5
6pub struct RpcClient;
7
8impl RpcClient {
9    /// Use the centralized ToolResolver instead of hardcoded tool matching
10    pub async fn call_tool(tool_name: &str, parameters: Value) -> Result<Value, BrightDataError> {
11        let resolver = ToolResolver::default();
12        
13        match resolver.resolve(tool_name) {
14            Some(tool) => {
15                // Use legacy method for backward compatibility
16                tool.execute_legacy(parameters).await
17            },
18            None => Err(BrightDataError::ToolError(format!(
19                "Unknown tool: {}",
20                tool_name
21            )))
22        }
23    }
24
25    /// Get list of available tools
26    pub fn list_available_tools() -> Vec<&'static str> {
27        ToolResolver::default().get_available_tool_names()
28    }
29}