|
1 | 1 | use anyhow::Result; |
2 | 2 | use rmcp::{ |
| 3 | + ServerHandler, ServiceExt, |
3 | 4 | handler::server::{router::tool::ToolRouter, tool::Parameters}, |
4 | 5 | model::*, |
5 | | - schemars, tool, tool_handler, tool_router, ServerHandler, ServiceExt, |
| 6 | + schemars, tool, tool_handler, tool_router, |
6 | 7 | }; |
7 | | -use serde::de::DeserializeOwned; |
8 | 8 | use serde::Deserialize; |
| 9 | +use serde::de::DeserializeOwned; |
9 | 10 |
|
10 | 11 | const NWS_API_BASE: &str = "https://api.weather.gov"; |
11 | 12 | const USER_AGENT: &str = "weather-app/1.0"; |
@@ -165,20 +166,14 @@ impl Weather { |
165 | 166 | }): Parameters<MCPForecastRequest>, |
166 | 167 | ) -> String { |
167 | 168 | let points_url = format!("{NWS_API_BASE}/points/{latitude},{longitude}"); |
168 | | - let points_data = match make_nws_request::<PointsResponse>(&points_url).await { |
169 | | - Ok(data) => data, |
170 | | - Err(_) => { |
171 | | - return "Unable to fetch forecast data for this location.".to_string(); |
172 | | - } |
| 169 | + let Ok(points_data) = make_nws_request::<PointsResponse>(&points_url).await else { |
| 170 | + return "Unable to fetch forecast data for this location.".to_string(); |
173 | 171 | }; |
174 | 172 |
|
175 | 173 | let forecast_url = points_data.properties.forecast; |
176 | 174 |
|
177 | | - let forecast_data = match make_nws_request::<ForecastResponse>(&forecast_url).await { |
178 | | - Ok(data) => data, |
179 | | - Err(_) => { |
180 | | - return "Unable to fetch forecast data for this location.".to_string(); |
181 | | - } |
| 175 | + let Ok(forecast_data) = make_nws_request::<ForecastResponse>(&forecast_url).await else { |
| 176 | + return "Unable to fetch forecast data for this location.".to_string(); |
182 | 177 | }; |
183 | 178 |
|
184 | 179 | let periods = &forecast_data.properties.periods; |
|
0 commit comments