Skip to content

Commit a48ef1e

Browse files
committed
Fix clippy finding
1 parent 83ab5ab commit a48ef1e

File tree

4 files changed

+56
-55
lines changed

4 files changed

+56
-55
lines changed

databroker-cli/src/kuksa_cli.rs

+38-40
Original file line numberDiff line numberDiff line change
@@ -676,47 +676,45 @@ pub async fn kuksa_main(_cli: Cli) -> Result<(), Box<dyn std::error::Error>> {
676676

677677
if paths.is_empty() {
678678
cli::print_info("If you want to list metadata of signals, use `metadata PATTERN`")?;
679-
} else {
680-
if let Some(entries) =
681-
handle_get_metadata(paths, &mut client).await.unwrap()
682-
{
683-
cli::print_resp_ok(cmd)?;
684-
if !entries.is_empty() {
685-
let max_len_path =
686-
entries.iter().fold(0, |mut max_len, item| {
687-
if item.path.len() > max_len {
688-
max_len = item.path.len();
689-
}
690-
max_len
691-
});
692-
693-
cli::print_info(format!(
694-
"{:<max_len_path$} {:<10} {:<9}",
695-
"Path", "Entry type", "Data type"
696-
))?;
697-
698-
for entry in &entries {
699-
if let Some(entry_metadata) = &entry.metadata {
700-
println!(
701-
"{:<max_len_path$} {:<10} {:<9}",
702-
entry.path,
703-
DisplayEntryType::from(
704-
proto::v1::EntryType::try_from(
705-
entry_metadata.entry_type
706-
)
707-
.ok()
708-
),
709-
DisplayDataType::from(
710-
proto::v1::DataType::try_from(
711-
entry_metadata.data_type
712-
)
713-
.ok()
714-
),
715-
);
716-
} else {
717-
let name = entry.path.clone();
718-
println!("No entry metadata for {name}");
679+
} else if let Some(entries) =
680+
handle_get_metadata(paths, &mut client).await.unwrap()
681+
{
682+
cli::print_resp_ok(cmd)?;
683+
if !entries.is_empty() {
684+
let max_len_path =
685+
entries.iter().fold(0, |mut max_len, item| {
686+
if item.path.len() > max_len {
687+
max_len = item.path.len();
719688
}
689+
max_len
690+
});
691+
692+
cli::print_info(format!(
693+
"{:<max_len_path$} {:<10} {:<9}",
694+
"Path", "Entry type", "Data type"
695+
))?;
696+
697+
for entry in &entries {
698+
if let Some(entry_metadata) = &entry.metadata {
699+
println!(
700+
"{:<max_len_path$} {:<10} {:<9}",
701+
entry.path,
702+
DisplayEntryType::from(
703+
proto::v1::EntryType::try_from(
704+
entry_metadata.entry_type
705+
)
706+
.ok()
707+
),
708+
DisplayDataType::from(
709+
proto::v1::DataType::try_from(
710+
entry_metadata.data_type
711+
)
712+
.ok()
713+
),
714+
);
715+
} else {
716+
let name = entry.path.clone();
717+
println!("No entry metadata for {name}");
720718
}
721719
}
722720
}

databroker-cli/src/sdv_cli.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
********************************************************************************/
1313

1414
use databroker_proto::sdv::databroker as proto;
15-
use kuksa_sdv::*;
1615
use kuksa_common::ClientTrait;
16+
use kuksa_sdv::*;
1717

1818
use prost_types::Timestamp;
1919
use tokio_stream::StreamExt;

lib/kuksa/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ impl kuksa_common::ClientTrait for KuksaClient {
112112
type DatapointType = HashMap<String, proto::v1::Datapoint>;
113113
type PathType = Vec<String>;
114114
type SubscribeType = Self::PathType;
115-
type PublishResponseType = ();
115+
type PublishResponseType = ();
116116
type GetResponseType = Vec<DataEntry>;
117-
type SubscribeResponseType = tonic::Streaming<proto::v1::SubscribeResponse>;
118-
type ProvideResponseType = tonic::Streaming<proto::v1::SubscribeResponse>;
119-
type ActuateResponseType = ();
117+
type SubscribeResponseType = tonic::Streaming<proto::v1::SubscribeResponse>;
118+
type ProvideResponseType = tonic::Streaming<proto::v1::SubscribeResponse>;
119+
type ActuateResponseType = ();
120120
type MetadataResponseType = Vec<DataEntry>;
121121

122122
async fn update_datapoints(

lib/sdv/src/lib.rs

+13-10
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,20 @@ impl kuksa_common::ClientTrait for SDVClient {
3535
type DatapointType = HashMap<String, proto::v1::Datapoint>;
3636
type PathType = Vec<String>;
3737
type SubscribeType = String;
38-
type PublishResponseType = proto::v1::UpdateDatapointsReply;
38+
type PublishResponseType = proto::v1::UpdateDatapointsReply;
3939
type GetResponseType = HashMap<std::string::String, proto::v1::Datapoint>;
40-
type SubscribeResponseType = tonic::Streaming<proto::v1::SubscribeReply>;
41-
type ProvideResponseType = ();
42-
type ActuateResponseType = proto::v1::SetDatapointsReply;
40+
type SubscribeResponseType = tonic::Streaming<proto::v1::SubscribeReply>;
41+
type ProvideResponseType = ();
42+
type ActuateResponseType = proto::v1::SetDatapointsReply;
4343
type MetadataResponseType = Vec<proto::v1::Metadata>;
4444
async fn update_datapoints(
4545
&mut self,
4646
datapoints: Self::DatapointType,
4747
) -> Result<Self::PublishResponseType, ClientError> {
48-
let metadata = self.get_metadata(datapoints.keys().cloned().collect()).await.unwrap();
48+
let metadata = self
49+
.get_metadata(datapoints.keys().cloned().collect())
50+
.await
51+
.unwrap();
4952
let id_datapoints: HashMap<i32, proto::v1::Datapoint> = metadata
5053
.into_iter()
5154
.map(|meta| meta.id)
@@ -57,7 +60,9 @@ impl kuksa_common::ClientTrait for SDVClient {
5760
self.basic_client.get_auth_interceptor(),
5861
);
5962

60-
let request = tonic::Request::new(proto::v1::UpdateDatapointsRequest { datapoints: id_datapoints });
63+
let request = tonic::Request::new(proto::v1::UpdateDatapointsRequest {
64+
datapoints: id_datapoints,
65+
});
6166
match client.update_datapoints(request).await {
6267
Ok(response) => Ok(response.into_inner()),
6368
Err(err) => Err(ClientError::Status(err)),
@@ -86,9 +91,7 @@ impl kuksa_common::ClientTrait for SDVClient {
8691
self.basic_client.get_channel().await?.clone(),
8792
self.basic_client.get_auth_interceptor(),
8893
);
89-
let args = tonic::Request::new(proto::v1::GetDatapointsRequest {
90-
datapoints: paths,
91-
});
94+
let args = tonic::Request::new(proto::v1::GetDatapointsRequest { datapoints: paths });
9295
match client.get_datapoints(args).await {
9396
Ok(response) => {
9497
let message = response.into_inner();
@@ -119,7 +122,7 @@ impl kuksa_common::ClientTrait for SDVClient {
119122

120123
async fn provide_actuation(
121124
&mut self,
122-
_paths: Self::PathType,
125+
_paths: Self::PathType,
123126
) -> Result<Self::ProvideResponseType, ClientError> {
124127
unimplemented!("No function in the RUST SDK sdv.databroker.v1 for getting target values")
125128
}

0 commit comments

Comments
 (0)