Skip to content

Commit

Permalink
Apply some clippy suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Egger <[email protected]>
  • Loading branch information
therealprof committed Dec 11, 2024
1 parent 5d6fc6f commit 887a1aa
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rustfmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo --all -- --check
- run: cargo fmt --all -- --check
8 changes: 4 additions & 4 deletions rusp-bin/src/bin/rusp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,11 @@ enum MsgType {
/// Generate an USP Get Response Message
#[command(name = "GetResp")]
USPGetResp {
/// A JSON array of Strings resembling the result data for the GetResp operation
/// A JSON array of Strings resembling the result data for the `GetResp` operation
#[arg(num_args(1..))]
result: Vec<String>,
},
/// Generate an USP GetInstances Request Message
/// Generate an USP `GetInstances` Request Message
#[command(name = "GetInstances")]
USPGetInstances {
/// Only return the first level of recursive structures?
Expand All @@ -397,7 +397,7 @@ enum MsgType {
#[arg(num_args(1..))]
obj_paths: Vec<String>,
},
/// Generate an USP GetSupportedDM Request Message
/// Generate an USP `GetSupportedDM` Request Message
#[command(name = "GetSupportedDM")]
USPGetSupportedDM {
/// Only return the first level of recursive structures?
Expand All @@ -421,7 +421,7 @@ enum MsgType {
#[arg(num_args(1..))]
paths: Vec<String>,
},
/// Generate an USP GetSupportedProtocol Request Message
/// Generate an USP `GetSupportedProtocol` Request Message
#[command(name = "GetSupportedProtocol")]
USPGetSupportedProtocol {
/// Controller Supported Protocol Version
Expand Down
6 changes: 3 additions & 3 deletions rusp-lib/src/usp_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ mod tests {
";

let rmsg = try_decode_msg(data).expect("deserialisation failed");
assert_eq!(msg, rmsg)
assert_eq!(msg, rmsg);
}

#[test]
Expand All @@ -589,7 +589,7 @@ mod tests {
";

let rmsg = try_decode_msg(data).expect("deserialisation failed");
assert_eq!(msg, rmsg)
assert_eq!(msg, rmsg);
}

#[test]
Expand Down Expand Up @@ -686,7 +686,7 @@ mod tests {
let data = b"\n\x1c\n\x18CXOue8V6Pg/hYC4bKfO8rw==\x10\x12\x12\t\x12\x07J\x05\n\x031.1";
let rmsg = try_decode_msg(data).expect("deserialisation failed");

assert_eq!(msg, rmsg)
assert_eq!(msg, rmsg);
}

#[test]
Expand Down
7 changes: 1 addition & 6 deletions rusp-lib/src/usp_builder/notify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,7 @@ impl NotifyBuilder {
product_class,
serial_number,
agent_supported_protocol_versions,
} => on_board_req(OnBoardRequest {
agent_supported_protocol_versions,
oui,
product_class,
serial_number,
}),
} => on_board_req(OnBoardRequest { oui, product_class, serial_number, agent_supported_protocol_versions }),
NotifyType::ValueChange {
param_path,
param_value,
Expand Down
6 changes: 3 additions & 3 deletions rusp-lib/src/usp_encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn try_encode_msg(msg: &Msg) -> Result<Vec<u8>> {

impl SessionContextRecord {
/// Creates a new [`SessionContextRecord`] with an unfragmented payload
pub fn new_unfragmented(
#[must_use] pub fn new_unfragmented(
session_id: u64,
sequence_id: u64,
expected_id: u64,
Expand Down Expand Up @@ -195,7 +195,7 @@ impl Record {
let mut out = String::new();

write!(out, "\"")?;
for i in data.iter() {
for i in &data {
if check_printable(*i) {
write!(out, "{}", char::from(*i))?;
} else {
Expand Down Expand Up @@ -398,7 +398,7 @@ impl Msg {
let mut out = String::new();

write!(out, "\"")?;
for i in data.iter() {
for i in &data {
if check_printable(*i) {
write!(out, "{}", char::from(*i))?;
} else {
Expand Down
4 changes: 2 additions & 2 deletions rusp-lib/tests/test_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mod tests {
let record = Record::from_reader(&mut reader, &bytes).expect("Cannot read Record");

let serialized = serde_json::to_string_pretty(&record).unwrap();
println!("serialized = {}", serialized);
println!("serialized = {serialized}");
assert_eq!(
serialized,
r#"{
Expand Down Expand Up @@ -189,7 +189,7 @@ mod tests {
let record = Record::from_reader(&mut reader, &bytes).expect("Cannot read Record");

let serialized = serde_json::to_string_pretty(&record).unwrap();
println!("serialized = {}", serialized);
println!("serialized = {serialized}");
assert_eq!(
serialized,
r#"{
Expand Down

0 comments on commit 887a1aa

Please sign in to comment.