Skip to content

Commit dfcffb0

Browse files
authored
chore(deps): bump quick-xml to 0.42 in /backend (#1042)
0.42 decodes to `str` at the API boundary: `local_name().as_ref()` and `Event::Text::as_ref()` return `&str`, and an attribute value is a `Cow<'_, str>`. The `from_utf8` calls in `parse_timeseries_xml` come out, and the text branch loses a fallible layer with them.
1 parent c651aaa commit dfcffb0

3 files changed

Lines changed: 17 additions & 24 deletions

File tree

‎backend/Cargo.lock‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎backend/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
2323
rusqlite = { version = "0.40", features = ["bundled"] }
2424
chrono = { version = "0.4", features = ["serde"] }
2525
chrono-tz = "0.10"
26-
quick-xml = "0.41"
26+
quick-xml = "0.42"
2727
sun = "0.3"
2828
solar-positioning = "0.5"
2929
hmac = "0.13.0"

‎backend/src/weather/fmi/client.rs‎

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,11 @@ fn parse_timeseries_xml(xml: &str) -> Result<ParameterMap, FmiError> {
235235
match reader.read_event_into(&mut buf) {
236236
Ok(Event::Start(ref e)) | Ok(Event::Empty(ref e)) => {
237237
let ln = e.local_name();
238-
let local_name = std::str::from_utf8(ln.as_ref()).unwrap_or_default();
239-
match local_name {
238+
match ln.as_ref() {
240239
"MeasurementTimeseries" => {
241240
for attr in e.attributes().flatten() {
242-
let kn = attr.key.local_name();
243-
let key = std::str::from_utf8(kn.as_ref()).unwrap_or_default();
244-
if key == "id" {
245-
let id = std::str::from_utf8(&attr.value).unwrap_or_default();
246-
if let Some(name) = extract_param_name(id) {
241+
if attr.key.local_name().as_ref() == "id" {
242+
if let Some(name) = extract_param_name(attr.value.as_ref()) {
247243
current_param = Some(name);
248244
}
249245
}
@@ -256,8 +252,7 @@ fn parse_timeseries_xml(xml: &str) -> Result<ParameterMap, FmiError> {
256252
}
257253
Ok(Event::End(ref e)) => {
258254
let ln = e.local_name();
259-
let local_name = std::str::from_utf8(ln.as_ref()).unwrap_or_default();
260-
match local_name {
255+
match ln.as_ref() {
261256
"MeasurementTimeseries" => {
262257
current_param = None;
263258
}
@@ -270,18 +265,16 @@ fn parse_timeseries_xml(xml: &str) -> Result<ParameterMap, FmiError> {
270265
}
271266
}
272267
Ok(Event::Text(ref e)) => {
273-
if let Ok(text) = std::str::from_utf8(e.as_ref()) {
274-
let text = text.trim().to_string();
275-
if in_time {
276-
current_time = Some(text);
277-
} else if in_value {
278-
if let (Some(param), Some(time_str)) = (&current_param, &current_time) {
279-
if text != "NaN" {
280-
if let (Ok(time), Ok(val)) =
281-
(time_str.parse::<DateTime<Utc>>(), text.parse::<f64>())
282-
{
283-
params.entry(param.clone()).or_default().insert(time, val);
284-
}
268+
let text = e.as_ref().trim().to_string();
269+
if in_time {
270+
current_time = Some(text);
271+
} else if in_value {
272+
if let (Some(param), Some(time_str)) = (&current_param, &current_time) {
273+
if text != "NaN" {
274+
if let (Ok(time), Ok(val)) =
275+
(time_str.parse::<DateTime<Utc>>(), text.parse::<f64>())
276+
{
277+
params.entry(param.clone()).or_default().insert(time, val);
285278
}
286279
}
287280
}

0 commit comments

Comments
 (0)