From 6f89dc33fd8ddd1953b1c30a87f9fe9bb4a890f3 Mon Sep 17 00:00:00 2001 From: Rafael RL Date: Mon, 23 Oct 2023 11:03:49 +0200 Subject: [PATCH] Format and clippy --- kuksa_databroker/databroker/src/broker.rs | 5 +-- .../databroker/src/grpc/kuksa_val_v1/val.rs | 44 +++++++++---------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/kuksa_databroker/databroker/src/broker.rs b/kuksa_databroker/databroker/src/broker.rs index 8bae0e5d..40f9d4e5 100644 --- a/kuksa_databroker/databroker/src/broker.rs +++ b/kuksa_databroker/databroker/src/broker.rs @@ -2789,10 +2789,7 @@ mod tests { .expect("Register datapoint should succeed"); let mut stream = broker - .subscribe(HashMap::from([( - id1, - HashSet::from([Field::Datapoint]), - )])) + .subscribe(HashMap::from([(id1, HashSet::from([Field::Datapoint]))])) .await .expect("subscription should succeed"); diff --git a/kuksa_databroker/databroker/src/grpc/kuksa_val_v1/val.rs b/kuksa_databroker/databroker/src/grpc/kuksa_val_v1/val.rs index 9e4b59e1..dcbc2f7f 100644 --- a/kuksa_databroker/databroker/src/grpc/kuksa_val_v1/val.rs +++ b/kuksa_databroker/databroker/src/grpc/kuksa_val_v1/val.rs @@ -385,30 +385,30 @@ impl proto::val_server::Val for broker::DataBroker { let regex_exp = glob::to_regex(&entry.path); if let Ok(regex) = regex_exp { - broker.for_each_entry(|for_each_entry| { - let entry_path = &for_each_entry.metadata().path; - if regex.is_match(entry_path) { - let mut fields = HashSet::new(); - for id in &entry.fields { - match proto::Field::from_i32(*id) { - Some(field) => match field { - proto::Field::Value => { - fields.insert(broker::Field::Datapoint); - } - proto::Field::ActuatorTarget => { - fields.insert(broker::Field::ActuatorTarget); - } - _ => { - // Just ignore other fields for now + broker + .for_each_entry(|for_each_entry| { + let entry_path = &for_each_entry.metadata().path; + if regex.is_match(entry_path) { + let mut fields = HashSet::new(); + for id in &entry.fields { + if let Some(field) = proto::Field::from_i32(*id) { + match field { + proto::Field::Value => { + fields.insert(broker::Field::Datapoint); + } + proto::Field::ActuatorTarget => { + fields.insert(broker::Field::ActuatorTarget); + } + _ => { + // Just ignore other fields for now + } } - }, - None => {} - }; + }; + } + entries.insert(for_each_entry.metadata().id, fields); } - entries.insert(for_each_entry.metadata().id, fields); - } - }) - .await; + }) + .await; } }