From f6899bee6675b3c4274f8838d6fb4b1310e7bead Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Mon, 1 Jul 2024 13:57:31 +0300 Subject: [PATCH] Minor linting Fixed a number of compiler warnings, minor spelling, and ran `cargo fmt` --- Cargo.toml | 13 +++-- examples/kwp.rs | 25 +++++++--- src/channel.rs | 22 +++++--- src/dynamic_diag.rs | 69 ++++++++++++++++---------- src/hardware/mod.rs | 8 ++- src/hardware/passthru/mod.rs | 14 ++++-- src/hardware/passthru/sw_isotp.rs | 13 +++-- src/hardware/socketcan.rs | 34 ++++++------- src/kwp2000/read_data_by_identifier.rs | 5 +- src/kwp2000/read_data_by_local_id.rs | 5 +- src/kwp2000/read_dtc_by_status.rs | 2 +- src/lib.rs | 26 +++++++--- src/obd2/enumerations.rs | 8 +-- 13 files changed, 152 insertions(+), 92 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6f5dd88..6145970 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,19 +23,18 @@ targets = ["x86_64-unknown-linux-gnu", "i686-pc-windows-msvc", "x86_64-apple-dar [features] default = ["passthru", "socketcan"] -socketcan = ["dep:socketcan-isotp", "dep:socketcan"] passthru = ["dep:libloading", "dep:shellexpand", "dep:winreg", "dep:serde_json", "dep:j2534_rust"] +socketcan = ["dep:socketcan-isotp", "dep:socketcan"] [dependencies] -#automotive_diag = { version = "0.1", path = "../automotive_diag" } automotive_diag = "0.1" j2534_rust = { version = "1.5.0", optional = true } -serde_json = { version = "1.0.79", optional = true } libloading = { version = "0.7.3", optional = true } -log="0.4.16" +log = "0.4.16" +serde_json = { version = "1.0.79", optional = true } strum = "0.24" strum_macros = "0.24" -thiserror="1.0.44" +thiserror = "1.0.44" [dev-dependencies] env_logger = "0.10.0" @@ -49,3 +48,7 @@ shellexpand = { version = "2.1.0", optional = true } [target.'cfg(target_os = "linux")'.dependencies] socketcan-isotp = { optional = true, version = "1.0.1" } socketcan = { version = "2.0.0", optional = true } + +#[patch.crates-io] +## Enable local automotive_diag crate for development +#automotive_diag = { path = "../automotive_diag" } diff --git a/examples/kwp.rs b/examples/kwp.rs index ee72abf..929c060 100644 --- a/examples/kwp.rs +++ b/examples/kwp.rs @@ -1,13 +1,16 @@ use automotive_diag::kwp2000::{KwpSessionType, KwpSessionTypeByte}; -use std::{time::Duration, sync::{Arc, RwLock}}; +use std::{ + sync::{Arc, RwLock}, + time::Duration, +}; use ecu_diagnostics::{ - channel::{self, IsoTPSettings}, + channel::IsoTPSettings, dynamic_diag::{ - DiagProtocol, DiagServerAdvancedOptions, DiagServerBasicOptions, DiagSessionMode, - DynamicDiagSession, TimeoutConfig, DiagServerEmptyLogger, + DiagProtocol, DiagServerAdvancedOptions, DiagServerBasicOptions, DiagServerEmptyLogger, + DiagSessionMode, DynamicDiagSession, TimeoutConfig, }, - hardware::{self, HardwareScanner, Hardware}, + hardware::{Hardware, HardwareScanner}, kwp2000::Kwp2000Protocol, }; @@ -79,7 +82,7 @@ fn main() { tp_ext_id: None, command_cooldown_ms: 100, }), - DiagServerEmptyLogger{} + DiagServerEmptyLogger {}, ) .unwrap(); @@ -104,10 +107,16 @@ fn main() { let res = diag_server.kwp_set_session(KwpSessionTypeByte::from(0x93)); // Same ID as what we registered at the start println!("Into special diag mode result: {:?}", res); print_diag_mode(&diag_server); - println!("Reset result: {:?}", diag_server.kwp_reset_ecu(automotive_diag::kwp2000::ResetType::PowerOnReset)); + println!( + "Reset result: {:?}", + diag_server.kwp_reset_ecu(automotive_diag::kwp2000::ResetType::PowerOnReset) + ); print_diag_mode(&diag_server); // ECU should be in standard mode now as the ECU was rebooted std::thread::sleep(Duration::from_millis(500)); - println!("Read op: {:?}", diag_server.kwp_enable_normal_message_transmission()); + println!( + "Read op: {:?}", + diag_server.kwp_enable_normal_message_transmission() + ); print_diag_mode(&diag_server); // ECU will automatically be put into 0x93 mode // (Last requested mode as enable_normal_message_transmission cannot be ran in standard mode) loop { diff --git a/src/channel.rs b/src/channel.rs index 4035cde..a1ead3e 100644 --- a/src/channel.rs +++ b/src/channel.rs @@ -9,8 +9,8 @@ use std::{ sync::{mpsc, Arc, Mutex, PoisonError}, }; -#[cfg(all(feature="socketcan", target_os="linux"))] -use socketcan::{EmbeddedFrame, Id, ExtendedId, StandardId, CanDataFrame}; +#[cfg(all(feature = "socketcan", target_os = "linux"))] +use socketcan::{CanDataFrame, EmbeddedFrame, ExtendedId, Id, StandardId}; use crate::hardware::HardwareError; @@ -22,7 +22,11 @@ pub type ChannelResult = Result; pub enum ChannelError { /// Underlying IO Error with channel #[error("Device IO error")] - IOError(#[from] #[source] Arc), + IOError( + #[from] + #[source] + Arc, + ), /// Timeout when writing data to the channel #[error("Write timeout")] WriteTimeout, @@ -43,7 +47,11 @@ pub enum ChannelError { InterfaceNotOpen, /// Underlying API error with hardware #[error("Device hardware API error")] - HardwareError(#[from] #[source] HardwareError), + HardwareError( + #[from] + #[source] + HardwareError, + ), /// Channel not configured prior to opening #[error("Channel configuration error")] ConfigurationError, @@ -448,7 +456,7 @@ impl Packet for CanFrame { } } -#[cfg(all(feature="socketcan", target_os="linux"))] +#[cfg(all(feature = "socketcan", target_os = "linux"))] impl From for CanFrame { fn from(value: CanDataFrame) -> Self { let (id, ext) = match value.id() { @@ -459,12 +467,12 @@ impl From for CanFrame { } } -#[cfg(all(feature="socketcan", target_os="linux"))] +#[cfg(all(feature = "socketcan", target_os = "linux"))] impl Into for CanFrame { fn into(self) -> CanDataFrame { let id = match self.ext { true => Id::Extended(ExtendedId::new(self.get_address()).unwrap()), - false => Id::Standard(StandardId::new(self.get_address() as u16).unwrap()) + false => Id::Standard(StandardId::new(self.get_address() as u16).unwrap()), }; CanDataFrame::new(id, self.get_data()).unwrap() } diff --git a/src/dynamic_diag.rs b/src/dynamic_diag.rs index b7ff253..ac8c494 100644 --- a/src/dynamic_diag.rs +++ b/src/dynamic_diag.rs @@ -4,7 +4,8 @@ use std::{ collections::HashMap, sync::{ atomic::{AtomicBool, Ordering}, - mpsc::{Receiver, Sender}, Mutex, + mpsc::{Receiver, Sender}, + Mutex, }, time::Duration, }; @@ -134,15 +135,14 @@ pub enum ServerEvent { /// Diag server logger pub trait DiagServerLogger: Clone + Send + Sync { /// When a diagnostic server event happens - fn on_event(&self, _evt: ServerEvent){} + fn on_event(&self, _evt: ServerEvent) {} } #[derive(Debug, Copy, Clone)] /// Diag server basic logger (Use this if no logger is to be used in your application) -pub struct DiagServerEmptyLogger{} +pub struct DiagServerEmptyLogger {} -impl DiagServerLogger for DiagServerEmptyLogger { -} +impl DiagServerLogger for DiagServerEmptyLogger {} #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] /// Diagnostic session mode @@ -255,8 +255,8 @@ pub struct DynamicDiagSession { running: Arc, } -unsafe impl Sync for DynamicDiagSession{} -unsafe impl Send for DynamicDiagSession{} +unsafe impl Sync for DynamicDiagSession {} +unsafe impl Send for DynamicDiagSession {} impl std::fmt::Debug for DynamicDiagSession { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { @@ -277,12 +277,12 @@ impl DynamicDiagSession { channel_cfg: IsoTPSettings, basic_opts: DiagServerBasicOptions, advanced_opts: Option, - mut logger: L + mut logger: L, ) -> DiagServerResult where P: DiagProtocol + 'static, NRC: EcuNRC, - L: DiagServerLogger + 'static + L: DiagServerLogger + 'static, { // Create iso tp channel using provided HW interface. If this fails, we cannot setup KWP or UDS session! channel.set_iso_tp_cfg(channel_cfg)?; @@ -322,8 +322,8 @@ impl DynamicDiagSession { let mut tx_addr = basic_opts.send_id; match protocol.process_req_payload(&req.payload) { DiagAction::SetSessionMode(mode) => { - let mut needs_response = true; - let mut ext_id = None; + let needs_response = true; + let ext_id = None; let res = send_recv_ecu_req::( tx_addr, rx_addr, @@ -335,7 +335,7 @@ impl DynamicDiagSession { 0, &mut channel, &is_connected_inner, - &mut logger + &mut logger, ); if res.is_ok() { // Send OK! We can set diag mode in the server side @@ -359,7 +359,7 @@ impl DynamicDiagSession { 0, &mut channel, &is_connected_inner, - &mut logger + &mut logger, ); if res.is_ok() { log::debug!("ECU Reset detected. Setting default session mode"); @@ -386,7 +386,7 @@ impl DynamicDiagSession { 0, &mut channel, &is_connected_inner, - &mut logger + &mut logger, ); if let DiagServerRx::EcuError { b, desc: _ } = &resp { if NRC::from(*b).is_wrong_diag_mode() { @@ -394,7 +394,7 @@ impl DynamicDiagSession { // Wrong diag mode. We need to see if we need to change modes // Switch modes! tx_resp.send(DiagServerRx::EcuBusy); // Until we have a hook for this specific scenerio - // Now create new diag server request message + // Now create new diag server request message let mut needs_response = true; let mut ext_id = None; if let Some(adv) = advanced_opts { @@ -421,11 +421,13 @@ impl DynamicDiagSession { 0, &mut channel, &is_connected_inner, - &mut logger + &mut logger, ) .is_ok() { - log::debug!("ECU mode switch OK. Resending the request"); + log::debug!( + "ECU mode switch OK. Resending the request" + ); *noti_session_mode_t.write().unwrap() = current_session_mode.clone(); last_tp_time = Instant::now(); @@ -441,7 +443,7 @@ impl DynamicDiagSession { 0, &mut channel, &is_connected_inner, - &mut logger + &mut logger, ); } else { // Diag session mode req failed. Set session data @@ -456,7 +458,7 @@ impl DynamicDiagSession { tx_resp.send(resp); } } - } + } } if !do_cmd { if current_session_mode != requested_session_mode { @@ -488,7 +490,7 @@ impl DynamicDiagSession { 0, &mut channel, &is_connected_inner, - &mut logger + &mut logger, ) .is_err() { @@ -533,7 +535,12 @@ impl DynamicDiagSession { self.internal_send_byte_array(p, &lock, false) } - fn internal_send_byte_array(&self, p: &[u8], sender: &Sender, resp_require: bool) -> DiagServerResult<()> { + fn internal_send_byte_array( + &self, + p: &[u8], + sender: &Sender, + resp_require: bool, + ) -> DiagServerResult<()> { self.clear_rx_queue(); sender .send(DiagTxPayload { @@ -632,12 +639,12 @@ fn send_recv_ecu_req( cooldown: u32, channel: &mut Box, connect_state: &AtomicBool, - logger: &mut L + logger: &mut L, ) -> DiagServerRx where P: DiagProtocol, NRC: EcuNRC, - L: DiagServerLogger + L: DiagServerLogger, { // Send the request, and transmit the send state! let mut res: ChannelResult<()> = Ok(()); @@ -659,7 +666,11 @@ where match res { Ok(_) => { if !payload.is_empty() { - logger.on_event(ServerEvent::BytesSendState(tx_addr, payload.to_vec(), Ok(()))); + logger.on_event(ServerEvent::BytesSendState( + tx_addr, + payload.to_vec(), + Ok(()), + )); } if needs_response { log::debug!("Sending OK, awaiting response from ECU"); @@ -706,7 +717,7 @@ where cooldown, channel, connect_state, - logger + logger, ) } else if nrc_data.is_repeat_request() { // ECU wants us to ask again, so we wait a little bit, then call ourselves again @@ -723,7 +734,7 @@ where cooldown, channel, connect_state, - logger + logger, ) } else { // Unhandled NRC @@ -748,7 +759,11 @@ where } } Err(e) => { - logger.on_event(ServerEvent::BytesSendState(rx_addr, payload.to_vec(), Err(e.clone()))); + logger.on_event(ServerEvent::BytesSendState( + rx_addr, + payload.to_vec(), + Err(e.clone()), + )); log::error!("Channel send error: {e}"); // Final error here at send state :( connect_state.store(false, Ordering::Relaxed); diff --git a/src/hardware/mod.rs b/src/hardware/mod.rs index 5293f1f..50ad9d8 100644 --- a/src/hardware/mod.rs +++ b/src/hardware/mod.rs @@ -10,7 +10,7 @@ pub mod passthru; // Not finished at all yet, hide from the crate #[cfg(feature = "passthru")] use std::sync::Arc; -#[cfg(all(feature="socketcan", target_os="linux"))] +#[cfg(all(feature = "socketcan", target_os = "linux"))] pub mod socketcan; use crate::channel::{CanChannel, IsoTPChannel}; @@ -116,7 +116,11 @@ pub enum HardwareError { /// Lib loading error #[cfg(feature = "passthru")] #[error("Device API library load error")] - LibLoadError(#[from] #[source] Arc), + LibLoadError( + #[from] + #[source] + Arc, + ), } #[cfg(feature = "passthru")] diff --git a/src/hardware/passthru/mod.rs b/src/hardware/passthru/mod.rs index dfa659f..d1b0554 100644 --- a/src/hardware/passthru/mod.rs +++ b/src/hardware/passthru/mod.rs @@ -20,7 +20,7 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::{ffi::c_void, time::Instant}; -use std::sync::{Arc, RwLock, Mutex}; +use std::sync::{Arc, Mutex, RwLock}; #[cfg(windows)] use winreg::enums::*; @@ -281,7 +281,7 @@ impl PassthruDevice { info.function_lib ); let lib = info.function_lib.clone(); - let drv = Arc::new(Mutex::new(lib_funcs::PassthruDrv::load_lib(lib)?)); + let drv = Arc::new(Mutex::new(PassthruDrv::load_lib(lib)?)); let mut lck = drv.lock().unwrap(); let idx = lck.open()?; let mut ret = Self { @@ -375,7 +375,9 @@ impl PassthruDevice { if !self.info.capabilities.can { return Err(HardwareError::ChannelNotSupported); } - if self.can_channel.load(Ordering::Relaxed) && !self.software_mode.load(Ordering::Relaxed) { + if self.can_channel.load(Ordering::Relaxed) + && !self.software_mode.load(Ordering::Relaxed) + { return Err(HardwareError::ConflictingChannel); } } @@ -522,7 +524,8 @@ impl PacketChannel for PassthruCanChannel { flags |= ConnectFlags::CAN_29BIT_ID; } // Initialize the interface - let channel_id = self.device + let channel_id = self + .device .safe_passthru_op(|device_id, device| { device.connect(device_id, Protocol::CAN, flags.bits(), self.baud) }) @@ -668,7 +671,8 @@ impl PayloadChannel for PassthruIsoTpChannel { } // Initialize the interface - let channel_id = self.device + let channel_id = self + .device .safe_passthru_op(|device_id, device| { device.connect( device_id, diff --git a/src/hardware/passthru/sw_isotp.rs b/src/hardware/passthru/sw_isotp.rs index 9a16a2a..7e98c9f 100644 --- a/src/hardware/passthru/sw_isotp.rs +++ b/src/hardware/passthru/sw_isotp.rs @@ -1,6 +1,6 @@ use std::borrow::BorrowMut; use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::{mpsc, Mutex, Arc}; +use std::sync::{mpsc, Arc, Mutex}; use std::thread::JoinHandle; use std::time::{Duration, Instant}; use std::vec; @@ -81,7 +81,8 @@ impl PtCombiChannel { pub fn new(mut dev: PassthruDevice) -> HardwareResult { { log::debug!("SW Combi channel constructor called"); - if dev.can_channel.load(Ordering::Relaxed) || dev.isotp_channel.load(Ordering::Relaxed) { + if dev.can_channel.load(Ordering::Relaxed) || dev.isotp_channel.load(Ordering::Relaxed) + { // Cannot proceed as dedicated CAN or ISO-TP dedicated channel is already open log::error!("CAN/ISO-TP dedicated channel already open"); return Err(HardwareError::ConflictingChannel); @@ -374,7 +375,9 @@ impl PtCombiChannel { 100, ) { isotp_rx = None; // Could not send FC - log::error!("Could not send FC to ECU: {e}"); + log::error!( + "Could not send FC to ECU: {e}" + ); } rx_frames_received = 0; // Send FC @@ -475,9 +478,9 @@ impl PtCombiChannel { // Now decide how long to sleep for if iso_tp_cfg.is_none() { - std::thread::sleep(std::time::Duration::from_millis(10)); + std::thread::sleep(Duration::from_millis(10)); } else { - std::thread::sleep(std::time::Duration::from_millis(1)); + std::thread::sleep(Duration::from_millis(1)); } } // Teardown diff --git a/src/hardware/socketcan.rs b/src/hardware/socketcan.rs index 23cf0ea..d82f93e 100644 --- a/src/hardware/socketcan.rs +++ b/src/hardware/socketcan.rs @@ -1,10 +1,14 @@ //! SocketCAN module use std::{ + borrow::BorrowMut, + io::ErrorKind, path::PathBuf, - sync::{Arc, atomic::{AtomicBool, Ordering}}, - io::ErrorKind, borrow::BorrowMut, - time::{Instant, Duration}, + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, + }, + time::{Duration, Instant}, }; use socketcan::Socket; @@ -15,8 +19,8 @@ use socketcan_isotp::{ }; use crate::channel::{ - CanChannel, CanFrame, ChannelError, ChannelResult, IsoTPChannel, IsoTPSettings, - PacketChannel, PayloadChannel, + CanChannel, CanFrame, ChannelError, ChannelResult, IsoTPChannel, IsoTPSettings, PacketChannel, + PayloadChannel, }; use super::{Hardware, HardwareCapabilities, HardwareError, HardwareInfo, HardwareScanner}; @@ -149,7 +153,7 @@ impl PacketChannel for SocketCanCanChannel { iface.set_nonblocking(true)?; } else { iface.set_nonblocking(false)?; - iface.set_write_timeout(std::time::Duration::from_millis(timeout_ms as u64))?; + iface.set_write_timeout(Duration::from_millis(timeout_ms as u64))?; } let mut cf: SocketCanCanFrame; for p in packets { @@ -178,10 +182,9 @@ impl PacketChannel for SocketCanCanChannel { } else { Ok(result) } - } else { iface.set_nonblocking(false)?; - iface.set_read_timeout(std::time::Duration::from_millis(timeout_ms as u64))?; + iface.set_read_timeout(Duration::from_millis(timeout_ms as u64))?; let start = Instant::now(); while start.elapsed().as_millis() <= timeout_ms as u128 { let f = iface.read_frame()?; @@ -198,12 +201,11 @@ impl PacketChannel for SocketCanCanChannel { Ok(result) } } - }) } fn clear_rx_buffer(&mut self) -> ChannelResult<()> { - while self.read_packets(1, 0).is_ok(){} + while self.read_packets(1, 0).is_ok() {} Ok(()) } @@ -282,7 +284,7 @@ impl PayloadChannel for SocketCanIsoTPChannel { let opts: IsoTpOptions = IsoTpOptions::new( flags, - std::time::Duration::from_millis(0), + Duration::from_millis(0), ext_address, 0xCC, 0xCC, @@ -508,20 +510,14 @@ impl HardwareScanner for SocketCanScanner { self.devices.clone() } - fn open_device_by_index( - &self, - idx: usize, - ) -> super::HardwareResult { + fn open_device_by_index(&self, idx: usize) -> super::HardwareResult { match self.devices.get(idx) { Some(hw) => Ok(SocketCanDevice::new(hw.name.clone())), None => Err(HardwareError::DeviceNotFound), } } - fn open_device_by_name( - &self, - name: &str, - ) -> super::HardwareResult { + fn open_device_by_name(&self, name: &str) -> super::HardwareResult { match self.devices.iter().find(|x| x.name == name) { Some(hw) => Ok(SocketCanDevice::new(hw.name.clone())), None => Err(HardwareError::DeviceNotFound), diff --git a/src/kwp2000/read_data_by_identifier.rs b/src/kwp2000/read_data_by_identifier.rs index 9c34de8..e355d7f 100644 --- a/src/kwp2000/read_data_by_identifier.rs +++ b/src/kwp2000/read_data_by_identifier.rs @@ -25,7 +25,10 @@ impl DynamicDiagSession { } let ident_response = ((res[1] as u16) << 8) | (res[2] as u16); if ident_response != identifier { - return Err(DiagError::MismatchedIdentResponse{ want: identifier, received: ident_response }); + return Err(DiagError::MismatchedIdentResponse { + want: identifier, + received: ident_response, + }); } res.drain(0..3); Ok(res) diff --git a/src/kwp2000/read_data_by_local_id.rs b/src/kwp2000/read_data_by_local_id.rs index 6a9e564..e13f225 100644 --- a/src/kwp2000/read_data_by_local_id.rs +++ b/src/kwp2000/read_data_by_local_id.rs @@ -252,7 +252,10 @@ impl DynamicDiagSession { return Err(DiagError::InvalidResponseLength); } if res[1] != local_identifier { - return Err(DiagError::MismatchedIdentResponse{ want: local_identifier as _, received: res[1] as _ }); + return Err(DiagError::MismatchedIdentResponse { + want: local_identifier as _, + received: res[1] as _, + }); } res.drain(0..2); Ok(res) diff --git a/src/kwp2000/read_dtc_by_status.rs b/src/kwp2000/read_dtc_by_status.rs index c273d4b..2a3a968 100644 --- a/src/kwp2000/read_dtc_by_status.rs +++ b/src/kwp2000/read_dtc_by_status.rs @@ -90,7 +90,7 @@ impl DynamicDiagSession { )?; match self.kwp_read_extended_supported_dtcs(range) { Ok(0) | Err(_) => break, // No more DTCs or error reading - Ok(_) => {}, + Ok(_) => {} } } diff --git a/src/lib.rs b/src/lib.rs index 9f3ba16..85622cd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![deny( +#![warn( missing_docs, missing_debug_implementations, missing_copy_implementations, @@ -109,21 +109,33 @@ pub enum DiagError { ParameterInvalid, /// Error with underlying communication channel #[error("Diagnostic server hardware channel error")] - ChannelError(#[from] #[source] ChannelError), + ChannelError( + #[from] + #[source] + ChannelError, + ), /// Device hardware error #[error("Diagnostic server hardware error")] - HardwareError(#[from] #[source] Arc), - /// Feauture is not iumplemented yet + HardwareError( + #[from] + #[source] + Arc, + ), + /// Feature is not implemented yet #[error("Diagnostic server feature is unimplemented: '{0}'")] NotImplemented(String), /// Mismatched PID response ID - #[error("Requested Ident 0x{:04X?}, but received ident 0x{:04X?}", want, received)] + #[error( + "Requested Ident 0x{:04X?}, but received ident 0x{:04X?}", + want, + received + )] MismatchedIdentResponse { /// Requested PID want: u16, /// Received PID from ECU - received: u16 - } + received: u16, + }, } /// Converts a single byte into a BCD string diff --git a/src/obd2/enumerations.rs b/src/obd2/enumerations.rs index fe23c10..eb7f586 100644 --- a/src/obd2/enumerations.rs +++ b/src/obd2/enumerations.rs @@ -35,19 +35,19 @@ impl Display for ObdEnumValue { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { ObdEnumValue::FuelSystemStatus(x) => match x { - Standard(v) => std::fmt::Display::fmt(&v, f), + Standard(v) => Display::fmt(&v, f), _ => f.write_fmt(format_args!("Extended({:#02X})", u32::from(*self))), }, ObdEnumValue::CommandedAirStatus(x) => match x { - Standard(v) => std::fmt::Display::fmt(&v, f), + Standard(v) => Display::fmt(&v, f), _ => f.write_fmt(format_args!("Extended({:#02X})", u32::from(*self))), }, ObdEnumValue::ObdStandard(x) => match x { - Standard(v) => std::fmt::Display::fmt(&v, f), + Standard(v) => Display::fmt(&v, f), _ => f.write_fmt(format_args!("Extended({:#02X})", u32::from(*self))), }, ObdEnumValue::FuelType(x) => match x { - Standard(v) => std::fmt::Display::fmt(&v, f), + Standard(v) => Display::fmt(&v, f), _ => f.write_fmt(format_args!("Extended({:#02X})", u32::from(*self))), }, }