From 649c4e0f9dadf836e84bdaa6279bc5b904863421 Mon Sep 17 00:00:00 2001 From: Andre Weber Date: Tue, 1 Oct 2024 15:26:34 +0200 Subject: [PATCH] Minor Renamings --- databroker/src/broker.rs | 26 ++++++++++++------------- databroker/src/grpc/kuksa_val_v2/val.rs | 6 +++--- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/databroker/src/broker.rs b/databroker/src/broker.rs index ccd8ed50..2c8d44fd 100644 --- a/databroker/src/broker.rs +++ b/databroker/src/broker.rs @@ -1676,7 +1676,7 @@ impl<'a, 'b> AuthorizedAccess<'a, 'b> { .iter() .flat_map(|subscription| subscription.vss_ids.clone()) .collect(); - let intersection: Vec<_> = vss_ids + let intersection: Vec<&i32> = vss_ids .iter() .filter(|&x| provided_vss_ids.contains(x)) .collect(); @@ -1706,17 +1706,18 @@ impl<'a, 'b> AuthorizedAccess<'a, 'b> { &self, actuation_changes: Vec, ) -> HashMap> { - let mut actuation_changes_per_vss_id: HashMap> = HashMap::new(); - for ele in actuation_changes { - let vss_id = ele.id; + let mut actuation_changes_per_vss_id: HashMap> = + HashMap::with_capacity(actuation_changes.len()); + for actuation_change in actuation_changes { + let vss_id = actuation_change.id; let opt_vss_ids = actuation_changes_per_vss_id.get_mut(&vss_id); match opt_vss_ids { Some(vss_ids) => { - vss_ids.push(ele.clone()); + vss_ids.push(actuation_change.clone()); } None => { - let vec = vec![ele.clone()]; + let vec = vec![actuation_change.clone()]; actuation_changes_per_vss_id.insert(vss_id, vec); } } @@ -1738,6 +1739,7 @@ impl<'a, 'b> AuthorizedAccess<'a, 'b> { for actuation_change in &actuation_changes { let vss_id = actuation_change.id; let result_entry = self.get_entry_by_id(vss_id).await; + match result_entry { Ok(entry) => { let vss_path = entry.metadata.path; @@ -1750,10 +1752,8 @@ impl<'a, 'b> AuthorizedAccess<'a, 'b> { return Err((ActuationError::PermissionDenied, message)); } Err(PermissionError::Expired) => { - return Err(( - ActuationError::PermissionExpired, - "Permission expired".to_string(), - )) + let message = "Permission expired".to_string(); + return Err((ActuationError::PermissionExpired, message)); } } } @@ -1807,9 +1807,9 @@ impl<'a, 'b> AuthorizedAccess<'a, 'b> { let actuation_changes_per_vss_id = &self .map_actuation_changes_by_vss_id(actuation_changes) .await; - for ele in actuation_changes_per_vss_id { - let vss_id = *ele.0; - let actuation_changes = ele.1.clone(); + for actuation_change_per_vss_id in actuation_changes_per_vss_id { + let vss_id = *actuation_change_per_vss_id.0; + let actuation_changes = actuation_change_per_vss_id.1.clone(); let opt_actuation_subscription = actuation_subscriptions .iter() diff --git a/databroker/src/grpc/kuksa_val_v2/val.rs b/databroker/src/grpc/kuksa_val_v2/val.rs index 7176c2b7..3e306d35 100644 --- a/databroker/src/grpc/kuksa_val_v2/val.rs +++ b/databroker/src/grpc/kuksa_val_v2/val.rs @@ -288,8 +288,8 @@ impl proto::val_server::Val for broker::DataBroker { let actuate_requests = request.into_inner().actuate_requests; let mut actuation_changes: Vec = vec![]; - for ele in actuate_requests { - let vss_id = match ele.signal_id { + for actuate_request in actuate_requests { + let vss_id = match actuate_request.signal_id { Some(signal_id) => match signal_id.signal { Some(proto::signal_id::Signal::Id(vss_id)) => vss_id, Some(proto::signal_id::Signal::Path(vss_path)) => { @@ -307,7 +307,7 @@ impl proto::val_server::Val for broker::DataBroker { }, None => return Err(tonic::Status::invalid_argument("Signal_Id not provided")), }; - let data_value = match ele.value { + let data_value = match actuate_request.value { Some(data_value) => DataValue::from(data_value), None => return Err(tonic::Status::invalid_argument("")), };