From 4e361e4421de5abfda9e6cc9b191d19b50fb5f82 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 26 Jan 2023 23:31:09 +0100 Subject: [PATCH] all clippy 1.67 fixes --- satrs-core/src/pool.rs | 20 +++++++-------- satrs-core/src/pus/verification.rs | 24 +++++++++--------- satrs-example/src/bin/simpleclient.rs | 35 ++++++++------------------- satrs-example/src/bin/test.rs | 2 +- satrs-example/src/pus.rs | 2 +- satrs-example/src/tmtc.rs | 10 ++++---- 6 files changed, 38 insertions(+), 55 deletions(-) diff --git a/satrs-core/src/pool.rs b/satrs-core/src/pool.rs index c04ccfd..9814be6 100644 --- a/satrs-core/src/pool.rs +++ b/satrs-core/src/pool.rs @@ -153,10 +153,10 @@ impl Display for StoreIdError { fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { match self { StoreIdError::InvalidSubpool(pool) => { - write!(f, "invalid subpool, index: {}", pool) + write!(f, "invalid subpool, index: {pool}") } StoreIdError::InvalidPacketIdx(packet_idx) => { - write!(f, "invalid packet index: {}", packet_idx) + write!(f, "invalid packet index: {packet_idx}") } } } @@ -183,19 +183,19 @@ impl Display for StoreError { fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { match self { StoreError::DataTooLarge(size) => { - write!(f, "data to store with size {} is too large", size) + write!(f, "data to store with size {size} is too large") } StoreError::StoreFull(u16) => { - write!(f, "store is too full. index for full subpool: {}", u16) + write!(f, "store is too full. index for full subpool: {u16}") } StoreError::InvalidStoreId(id_e, addr) => { - write!(f, "invalid store ID: {}, address: {:?}", id_e, addr) + write!(f, "invalid store ID: {id_e}, address: {addr:?}") } StoreError::DataDoesNotExist(addr) => { - write!(f, "no data exists at address {:?}", addr) + write!(f, "no data exists at address {addr:?}") } StoreError::InternalError(e) => { - write!(f, "internal error: {}", e) + write!(f, "internal error: {e}") } } } @@ -330,14 +330,12 @@ impl LocalPool { fn write(&mut self, addr: &StoreAddr, data: &[u8]) -> Result<(), StoreError> { let packet_pos = self.raw_pos(addr).ok_or_else(|| { StoreError::InternalError(format!( - "write: Error in raw_pos func with address {:?}", - addr + "write: Error in raw_pos func with address {addr:?}" )) })?; let subpool = self.pool.get_mut(addr.pool_idx as usize).ok_or_else(|| { StoreError::InternalError(format!( - "write: Error retrieving pool slice with address {:?}", - addr + "write: Error retrieving pool slice with address {addr:?}" )) })?; let pool_slice = &mut subpool[packet_pos..packet_pos + data.len()]; diff --git a/satrs-core/src/pus/verification.rs b/satrs-core/src/pus/verification.rs index 96c1073..5c7a4c7 100644 --- a/satrs-core/src/pus/verification.rs +++ b/satrs-core/src/pus/verification.rs @@ -522,9 +522,9 @@ impl VerificationReporterCore { ) } - pub fn send_acceptance_success<'src_data, E>( + pub fn send_acceptance_success( &self, - mut sendable: VerificationSendable<'src_data, TcStateNone, VerifSuccess>, + mut sendable: VerificationSendable<'_, TcStateNone, VerifSuccess>, seq_counter: &(impl SequenceCountProviderCore + ?Sized), sender: &mut (impl EcssTmSenderCore + ?Sized), ) -> Result, VerificationOrSendErrorWithToken> @@ -535,9 +535,9 @@ impl VerificationReporterCore { Ok(sendable.send_success_acceptance_success(Some(seq_counter))) } - pub fn send_acceptance_failure<'src_data, E>( + pub fn send_acceptance_failure( &self, - mut sendable: VerificationSendable<'src_data, TcStateNone, VerifFailure>, + mut sendable: VerificationSendable<'_, TcStateNone, VerifFailure>, seq_counter: &(impl SequenceCountProviderCore + ?Sized), sender: &mut (impl EcssTmSenderCore + ?Sized), ) -> Result<(), VerificationOrSendErrorWithToken> { @@ -591,9 +591,9 @@ impl VerificationReporterCore { ) } - pub fn send_start_success<'src_data, E>( + pub fn send_start_success( &self, - mut sendable: VerificationSendable<'src_data, TcStateAccepted, VerifSuccess>, + mut sendable: VerificationSendable<'_, TcStateAccepted, VerifSuccess>, seq_counter: &(impl SequenceCountProviderCore + ?Sized), sender: &mut (impl EcssTmSenderCore + ?Sized), ) -> Result< @@ -630,9 +630,9 @@ impl VerificationReporterCore { ) } - pub fn send_start_failure<'src_data, E>( + pub fn send_start_failure( &self, - mut sendable: VerificationSendable<'src_data, TcStateAccepted, VerifFailure>, + mut sendable: VerificationSendable<'_, TcStateAccepted, VerifFailure>, seq_counter: &(impl SequenceCountProviderCore + ?Sized), sender: &mut (impl EcssTmSenderCore + ?Sized), ) -> Result<(), VerificationOrSendErrorWithToken> { @@ -741,9 +741,9 @@ impl VerificationReporterCore { ) } - pub fn send_step_or_completion_success<'src_data, E>( + pub fn send_step_or_completion_success( &self, - mut sendable: VerificationSendable<'src_data, TcStateStarted, VerifSuccess>, + mut sendable: VerificationSendable<'_, TcStateStarted, VerifSuccess>, seq_counter: &(impl SequenceCountProviderCore + ?Sized), sender: &mut (impl EcssTmSenderCore + ?Sized), ) -> Result<(), VerificationOrSendErrorWithToken> { @@ -754,9 +754,9 @@ impl VerificationReporterCore { Ok(()) } - pub fn send_step_or_completion_failure<'src_data, E>( + pub fn send_step_or_completion_failure( &self, - mut sendable: VerificationSendable<'src_data, TcStateStarted, VerifFailure>, + mut sendable: VerificationSendable<'_, TcStateStarted, VerifFailure>, seq_counter: &(impl SequenceCountProviderCore + ?Sized), sender: &mut (impl EcssTmSenderCore + ?Sized), ) -> Result<(), VerificationOrSendErrorWithToken> { diff --git a/satrs-example/src/bin/simpleclient.rs b/satrs-example/src/bin/simpleclient.rs index e431eb5..83ec49f 100644 --- a/satrs-example/src/bin/simpleclient.rs +++ b/satrs-example/src/bin/simpleclient.rs @@ -14,16 +14,13 @@ fn main() { let pus_tc = PusTc::new_simple(&mut sph, 17, 1, None, true); let client = UdpSocket::bind("127.0.0.1:7302").expect("Connecting to UDP server failed"); let tc_req_id = RequestId::new(&pus_tc); - println!( - "Packing and sending PUS ping command TC[17,1] with request ID {}", - tc_req_id - ); + println!("Packing and sending PUS ping command TC[17,1] with request ID {tc_req_id}"); let size = pus_tc .write_to_bytes(&mut buf) .expect("Creating PUS TC failed"); client .send_to(&buf[0..size], addr) - .unwrap_or_else(|_| panic!("Sending to {:?} failed", addr)); + .unwrap_or_else(|_| panic!("Sending to {addr:?} failed")); client .set_read_timeout(Some(Duration::from_secs(2))) .expect("Setting read timeout failed"); @@ -44,33 +41,21 @@ fn main() { } let req_id = RequestId::from_bytes(src_data).unwrap(); if pus_tm.subservice() == 1 { - println!( - "Received TM[1,1] acceptance success for request ID {}", - req_id - ) + println!("Received TM[1,1] acceptance success for request ID {req_id}") } else if pus_tm.subservice() == 2 { - println!( - "Received TM[1,2] acceptance failure for request ID {}", - req_id - ) + println!("Received TM[1,2] acceptance failure for request ID {req_id}") } else if pus_tm.subservice() == 3 { - println!("Received TM[1,3] start success for request ID {}", req_id) + println!("Received TM[1,3] start success for request ID {req_id}") } else if pus_tm.subservice() == 4 { - println!("Received TM[1,2] start failure for request ID {}", req_id) + println!("Received TM[1,2] start failure for request ID {req_id}") } else if pus_tm.subservice() == 5 { - println!("Received TM[1,5] step success for request ID {}", req_id) + println!("Received TM[1,5] step success for request ID {req_id}") } else if pus_tm.subservice() == 6 { - println!("Received TM[1,6] step failure for request ID {}", req_id) + println!("Received TM[1,6] step failure for request ID {req_id}") } else if pus_tm.subservice() == 7 { - println!( - "Received TM[1,7] completion success for request ID {}", - req_id - ) + println!("Received TM[1,7] completion success for request ID {req_id}") } else if pus_tm.subservice() == 8 { - println!( - "Received TM[1,8] completion failure for request ID {}", - req_id - ); + println!("Received TM[1,8] completion failure for request ID {req_id}"); } } else { println!( diff --git a/satrs-example/src/bin/test.rs b/satrs-example/src/bin/test.rs index 41fb8e3..31b59dd 100644 --- a/satrs-example/src/bin/test.rs +++ b/satrs-example/src/bin/test.rs @@ -49,7 +49,7 @@ fn main() { let jh0 = thread::spawn(move || { let data = r0.recv().unwrap(); let raw = data.get_data(); - println!("Received data {:?}", raw); + println!("Received data {raw:?}"); }); let jh1 = thread::spawn(|| {}); jh0.join().unwrap(); diff --git a/satrs-example/src/pus.rs b/satrs-example/src/pus.rs index 108b086..e2de493 100644 --- a/satrs-example/src/pus.rs +++ b/satrs-example/src/pus.rs @@ -171,7 +171,7 @@ impl PusReceiver { let sender = self.request_map.get(&addressable_id.target_id).unwrap(); sender .send(RequestWithToken(Request::HkRequest(request), token)) - .unwrap_or_else(|_| panic!("Sending HK request {:?} failed", request)); + .unwrap_or_else(|_| panic!("Sending HK request {request:?} failed")); }; if PusPacket::subservice(pus_tc) == hk::Subservice::TcEnableGeneration as u8 { send_request(HkRequest::Enable(addressable_id)); diff --git a/satrs-example/src/tmtc.rs b/satrs-example/src/tmtc.rs index 4314deb..34d91a8 100644 --- a/satrs-example/src/tmtc.rs +++ b/satrs-example/src/tmtc.rs @@ -51,10 +51,10 @@ impl Display for MpscStoreAndSendError { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { MpscStoreAndSendError::StoreError(s) => { - write!(f, "store error {}", s) + write!(f, "store error {s}") } MpscStoreAndSendError::SendError(s) => { - write!(f, "send error {}", s) + write!(f, "send error {s}") } } } @@ -201,8 +201,8 @@ fn core_tmtc_loop( .ok(); } Err(e) => { - println!("error creating PUS TC from raw data: {}", e); - println!("raw data: {:x?}", data); + println!("error creating PUS TC from raw data: {e}"); + println!("raw data: {data:x?}"); } } } @@ -251,7 +251,7 @@ fn core_tm_handling(udp_tmtc_server: &mut UdpTmtcServer, recv_addr: &SocketAddr) if buf.len() > 9 { let service = buf[7]; let subservice = buf[8]; - println!("Sending PUS TM[{},{}]", service, subservice) + println!("Sending PUS TM[{service},{subservice}]") } else { println!("Sending PUS TM"); }