Skip to content

Commit 9f60cdc

Browse files
Clippy and format fixes
Signed-off-by: Sebastian Schildt <[email protected]>
1 parent 28e6091 commit 9f60cdc

File tree

12 files changed

+82
-108
lines changed

12 files changed

+82
-108
lines changed

databroker-cli/src/kuksa_cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ async fn handle_actuate_command(
125125
}
126126

127127
if metadata.entry_type != proto::v1::EntryType::Actuator as i32 {
128-
cli::print_error("actuate", format!("{} is not an actuator.", path))?;
128+
cli::print_error("actuate", format!("{path} is not an actuator."))?;
129129
continue;
130130
}
131131

databroker-cli/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ async fn main() {
2525
let err = sdv_cli::sdv_main(cli.clone()).await;
2626
match err {
2727
Ok(_) => (),
28-
Err(e) => eprintln!("Error: {}", e),
28+
Err(e) => eprintln!("Error: {e}"),
2929
}
3030
} else if cli.get_protocol() == Protocol::KuksaValV1 {
3131
let err = kuksa_cli::kuksa_main(cli.clone()).await;
3232
match err {
3333
Ok(_) => (),
34-
Err(e) => eprintln!("Error: {}", e),
34+
Err(e) => eprintln!("Error: {e}"),
3535
}
3636
} else {
3737
println!("Choose one protocol of either kuksa.val.v1 or sdv.databroker.v1")

databroker/src/authorization/jwt/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ AEiqOjPq0D6X45wCzIwjILUCAwEAAQ==
168168
Ok(claims) => {
169169
assert_eq!(claims.scope, "read:Vehicle.Speed");
170170
}
171-
Err(err) => panic!("decode should succeed but failed with:{}", err),
171+
Err(err) => panic!("decode should succeed but failed with:{err}"),
172172
}
173173
}
174174
}

databroker/src/broker.rs

Lines changed: 26 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,10 +1918,8 @@ impl AuthorizedAccess<'_, '_> {
19181918
.filter(|&x| provided_vss_ids.contains(x))
19191919
.collect();
19201920
if !intersection.is_empty() {
1921-
let message = format!(
1922-
"Providers for the following vss_ids already registered: {:?}",
1923-
intersection
1924-
);
1921+
let message =
1922+
format!("Providers for the following vss_ids already registered: {intersection:?}");
19251923
return Err((ActuationError::ProviderAlreadyExists, message));
19261924
}
19271925

@@ -1998,7 +1996,7 @@ impl AuthorizedAccess<'_, '_> {
19981996
}
19991997

20001998
if !actuation_subscription.actuation_provider.is_available() {
2001-
let message = format!("Provider for vss_id {} does not exist", vss_id);
1999+
let message = format!("Provider for vss_id {vss_id} does not exist");
20022000
return Err((ActuationError::ProviderNotAvailable, message));
20032001
}
20042002

@@ -2008,7 +2006,7 @@ impl AuthorizedAccess<'_, '_> {
20082006
.await?
20092007
}
20102008
None => {
2011-
let message = format!("Provider for vss_id {} not available", vss_id);
2009+
let message = format!("Provider for vss_id {vss_id} not available");
20122010
return Err((ActuationError::ProviderNotAvailable, message));
20132011
}
20142012
}
@@ -2044,7 +2042,7 @@ impl AuthorizedAccess<'_, '_> {
20442042
}
20452043

20462044
if !actuation_subscription.actuation_provider.is_available() {
2047-
let message = format!("Provider for vss_id {} does not exist", vss_id);
2045+
let message = format!("Provider for vss_id {vss_id} does not exist");
20482046
return Err((ActuationError::ProviderNotAvailable, message));
20492047
}
20502048

@@ -2057,7 +2055,7 @@ impl AuthorizedAccess<'_, '_> {
20572055
.await
20582056
}
20592057
None => {
2060-
let message = format!("Provider for vss_id {} does not exist", vss_id);
2058+
let message = format!("Provider for vss_id {vss_id} does not exist");
20612059
Err((ActuationError::ProviderNotAvailable, message))
20622060
}
20632061
}
@@ -2076,7 +2074,7 @@ impl AuthorizedAccess<'_, '_> {
20762074
match result_can_write_actuator {
20772075
Ok(_) => Ok(()),
20782076
Err(PermissionError::Denied) => {
2079-
let message = format!("Permission denied for vss_path {}", vss_path);
2077+
let message = format!("Permission denied for vss_path {vss_path}");
20802078
Err((ActuationError::PermissionDenied, message))
20812079
}
20822080
Err(PermissionError::Expired) => Err((
@@ -2086,11 +2084,11 @@ impl AuthorizedAccess<'_, '_> {
20862084
}
20872085
}
20882086
Err(ReadError::NotFound) => {
2089-
let message = format!("Could not resolve vss_path of vss_id {}", vss_id);
2087+
let message = format!("Could not resolve vss_path of vss_id {vss_id}");
20902088
Err((ActuationError::NotFound, message))
20912089
}
20922090
Err(ReadError::PermissionDenied) => {
2093-
let message = format!("Permission denied for vss_id {}", vss_id);
2091+
let message = format!("Permission denied for vss_id {vss_id}");
20942092
Err((ActuationError::PermissionDenied, message))
20952093
}
20962094
Err(ReadError::PermissionExpired) => Err((
@@ -2111,7 +2109,7 @@ impl AuthorizedAccess<'_, '_> {
21112109
let metadata = entry.metadata.clone();
21122110
let vss_path = metadata.path;
21132111
if metadata.entry_type != EntryType::Actuator {
2114-
let message = format!("Tried to set a value for a non-actuator: {}", vss_path);
2112+
let message = format!("Tried to set a value for a non-actuator: {vss_path}");
21152113
return Err((ActuationError::WrongType, message));
21162114
}
21172115
let validation = entry.validate_actuator_value(data_value);
@@ -2159,11 +2157,11 @@ impl AuthorizedAccess<'_, '_> {
21592157
}
21602158
// Redundant errors in case UpdateError includes new errors in the future
21612159
Err(UpdateError::NotFound) => {
2162-
let message = format!("Could not resolve vss_path {}", vss_path);
2160+
let message = format!("Could not resolve vss_path {vss_path}");
21632161
Err((ActuationError::NotFound, message))
21642162
}
21652163
Err(UpdateError::PermissionDenied) => {
2166-
let message = format!("Permission denied for vss_path {}", vss_path);
2164+
let message = format!("Permission denied for vss_path {vss_path}");
21672165
Err((ActuationError::PermissionDenied, message))
21682166
}
21692167
Err(UpdateError::PermissionExpired) => Err((
@@ -2173,11 +2171,11 @@ impl AuthorizedAccess<'_, '_> {
21732171
}
21742172
}
21752173
Err(ReadError::NotFound) => {
2176-
let message = format!("Could not resolve vss_path of vss_id {}", vss_id);
2174+
let message = format!("Could not resolve vss_path of vss_id {vss_id}");
21772175
Err((ActuationError::NotFound, message))
21782176
}
21792177
Err(ReadError::PermissionDenied) => {
2180-
let message = format!("Permission denied for vss_id {}", vss_id);
2178+
let message = format!("Permission denied for vss_id {vss_id}");
21812179
Err((ActuationError::PermissionDenied, message))
21822180
}
21832181
Err(ReadError::PermissionExpired) => Err((
@@ -2270,10 +2268,8 @@ impl AuthorizedAccess<'_, '_> {
22702268
.collect();
22712269

22722270
if !intersection.is_empty() {
2273-
let message = format!(
2274-
"Providers for the following vss_ids already registered: {:?}",
2275-
intersection
2276-
);
2271+
let message =
2272+
format!("Providers for the following vss_ids already registered: {intersection:?}");
22772273
return Err((RegisterSignalError::SignalAlreadyRegistered, message));
22782274
}
22792275

@@ -2314,10 +2310,8 @@ impl AuthorizedAccess<'_, '_> {
23142310
.collect();
23152311

23162312
if !intersection.is_empty() {
2317-
let message = format!(
2318-
"Providers for the following vss_ids already registered: {:?}",
2319-
intersection
2320-
);
2313+
let message =
2314+
format!("Providers for the following vss_ids already registered: {intersection:?}");
23212315
return Err((RegisterSignalError::SignalAlreadyRegistered, message));
23222316
}
23232317
self.broker
@@ -2833,10 +2827,7 @@ pub mod tests {
28332827
}
28342828
Err(e) => match e[0] {
28352829
(id, UpdateError::WrongType) => assert_eq!(id, id1),
2836-
_ => panic!(
2837-
"should have reported wrong type but got error of type {:?}",
2838-
e
2839-
),
2830+
_ => panic!("should have reported wrong type but got error of type {e:?}"),
28402831
},
28412832
}
28422833

@@ -4249,8 +4240,7 @@ pub mod tests {
42494240
Ok(()) => {}
42504241
Err(e) => {
42514242
panic!(
4252-
"Expected set_datapoints to succeed ( with Ok(()) ), instead got: Err({:?})",
4253-
e
4243+
"Expected set_datapoints to succeed ( with Ok(()) ), instead got: Err({e:?})"
42544244
)
42554245
}
42564246
}
@@ -4323,8 +4313,7 @@ pub mod tests {
43234313
Ok(_) => {}
43244314
Err(e) => {
43254315
panic!(
4326-
"Expected set_datapoints to succeed ( with Ok(()) ), instead got: Err({:?})",
4327-
e
4316+
"Expected set_datapoints to succeed ( with Ok(()) ), instead got: Err({e:?})"
43284317
)
43294318
}
43304319
}
@@ -4407,8 +4396,7 @@ pub mod tests {
44074396
Ok(_) => {}
44084397
Err(e) => {
44094398
panic!(
4410-
"Expected set_datapoints to succeed ( with Ok(()) ), instead got: Err({:?})",
4411-
e
4399+
"Expected set_datapoints to succeed ( with Ok(()) ), instead got: Err({e:?})"
44124400
)
44134401
}
44144402
}
@@ -4466,8 +4454,7 @@ pub mod tests {
44664454
Ok(_) => {}
44674455
Err(e) => {
44684456
panic!(
4469-
"Expected set_datapoints to succeed ( with Ok(()) ), instead got: Err({:?})",
4470-
e
4457+
"Expected set_datapoints to succeed ( with Ok(()) ), instead got: Err({e:?})"
44714458
)
44724459
}
44734460
}
@@ -4573,8 +4560,7 @@ pub mod tests {
45734560
Ok(()) => {}
45744561
Err(e) => {
45754562
panic!(
4576-
"Expected set_datapoints to succeed ( with Ok(()) ), instead got: Err({:?})",
4577-
e
4563+
"Expected set_datapoints to succeed ( with Ok(()) ), instead got: Err({e:?})"
45784564
)
45794565
}
45804566
}
@@ -4665,8 +4651,7 @@ pub mod tests {
46654651
Ok(()) => {}
46664652
Err(e) => {
46674653
panic!(
4668-
"Expected set_datapoints to succeed ( with Ok(()) ), instead got: Err({:?})",
4669-
e
4654+
"Expected set_datapoints to succeed ( with Ok(()) ), instead got: Err({e:?})"
46704655
)
46714656
}
46724657
}
@@ -4760,8 +4745,7 @@ pub mod tests {
47604745
Ok(()) => {}
47614746
Err(e) => {
47624747
panic!(
4763-
"Expected set_datapoints to succeed ( with Ok(()) ), instead got: Err({:?})",
4764-
e
4748+
"Expected set_datapoints to succeed ( with Ok(()) ), instead got: Err({e:?})"
47654749
)
47664750
}
47674751
}

databroker/src/grpc/kuksa_val_v1/val.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,12 +599,12 @@ impl proto::val_server::Val for broker::DataBroker {
599599
}
600600
}
601601
if !requested_path_found {
602-
let message = format!("No entries found for the provided. Path: {}", path);
602+
let message = format!("No entries found for the provided. Path: {path}");
603603
return Err(tonic::Status::new(tonic::Code::NotFound, message));
604604
}
605605
}
606606
if permission_error {
607-
let message = format!("Permission denied for some entries. Path: {}", path);
607+
let message = format!("Permission denied for some entries. Path: {path}");
608608
return Err(tonic::Status::new(tonic::Code::PermissionDenied, message));
609609
}
610610
}

databroker/src/grpc/kuksa_val_v2/conversions.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -357,35 +357,35 @@ impl broker::UpdateError {
357357
match self {
358358
broker::UpdateError::NotFound => tonic::Status::new(
359359
tonic::Code::NotFound,
360-
format!("Signal not found (id: {})", id),
360+
format!("Signal not found (id: {id})"),
361361
),
362362
broker::UpdateError::WrongType => tonic::Status::new(
363363
tonic::Code::InvalidArgument,
364-
format!("Wrong type provided (id: {})", id),
364+
format!("Wrong type provided (id: {id})"),
365365
),
366366
broker::UpdateError::OutOfBoundsAllowed => tonic::Status::new(
367367
tonic::Code::InvalidArgument,
368-
format!("Value out of allowed bounds (id: {})", id),
368+
format!("Value out of allowed bounds (id: {id})"),
369369
),
370370
broker::UpdateError::OutOfBoundsMinMax => tonic::Status::new(
371371
tonic::Code::InvalidArgument,
372-
format!("Value out of min/max bounds (id: {})", id),
372+
format!("Value out of min/max bounds (id: {id})"),
373373
),
374374
broker::UpdateError::OutOfBoundsType => tonic::Status::new(
375375
tonic::Code::InvalidArgument,
376-
format!("Value out of type bounds (id: {})", id),
376+
format!("Value out of type bounds (id: {id})"),
377377
),
378378
broker::UpdateError::UnsupportedType => tonic::Status::new(
379379
tonic::Code::InvalidArgument,
380-
format!("Unsupported type (id: {})", id),
380+
format!("Unsupported type (id: {id})"),
381381
),
382382
broker::UpdateError::PermissionDenied => tonic::Status::new(
383383
tonic::Code::PermissionDenied,
384-
format!("Permission denied (id: {})", id),
384+
format!("Permission denied (id: {id})"),
385385
),
386386
broker::UpdateError::PermissionExpired => tonic::Status::new(
387387
tonic::Code::Unauthenticated,
388-
format!("Permission expired (id: {})", id),
388+
format!("Permission expired (id: {id})"),
389389
),
390390
}
391391
}

0 commit comments

Comments
 (0)