From 07b6c49f6b6787591786b473a0e1dbf70bd0dfbc Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Tue, 25 Jun 2024 23:39:48 -0400 Subject: [PATCH 1/5] wip --- Cargo.toml | 6 ++++++ src/kwp2000/commands.rs | 1 + src/kwp2000/errors.rs | 1 + src/kwp2000/reset_types.rs | 1 + src/kwp2000/routine_exit_status.rs | 1 + src/kwp2000/session_types.rs | 1 + src/obd2/command_2nd_air_status.rs | 1 + src/obd2/commands.rs | 1 + src/obd2/data_pids.rs | 1 + src/obd2/errors.rs | 1 + src/obd2/fuel_system_status.rs | 1 + src/obd2/fuel_types.rs | 1 + src/obd2/obd_standard.rs | 1 + src/obd2/service09.rs | 1 + src/uds/comm_level.rs | 1 + src/uds/commands.rs | 28 ++++++++++++++++++++++++++++ src/uds/errors.rs | 1 + src/uds/read_dtc_information.rs | 1 + src/uds/reset_types.rs | 1 + src/uds/routine.rs | 1 + src/uds/scaling_byte.rs | 1 + src/uds/scaling_byte_ext.rs | 3 ++- src/uds/security_access.rs | 1 + src/uds/session_types.rs | 1 + src/utils.rs | 1 + 25 files changed, 58 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 45bf059..a21a41b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,13 +24,19 @@ with-kwp2000 = [] with-obd2 = [] # Include support for Unified Diagnostic Services with-uds = [] +# Include support for serde serialization +serde = ["dep:serde"] [dependencies] displaydoc = { version = "0.2", optional = true } strum = { version = "0.26.3", features = ["derive"] } +serde = { version = "1", optional = true } [dev-dependencies] cargo-husky = { version = "1", features = ["user-hooks"], default-features = false } +serde = { version = "1", features = ["derive"] } +serde_json = { version = "1", features = ["preserve_order"] } +insta = { version = "1.39" } [lints.rust] unsafe_code = "forbid" diff --git a/src/kwp2000/commands.rs b/src/kwp2000/commands.rs index bae315e..1093db2 100644 --- a/src/kwp2000/commands.rs +++ b/src/kwp2000/commands.rs @@ -7,6 +7,7 @@ crate::utils::enum_wrapper!(kwp2000, KwpCommand, KwpCommandByte); #[repr(u8)] #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum KwpCommand { /// Start or change ECU diagnostic session mode. StartDiagnosticSession = 0x10, diff --git a/src/kwp2000/errors.rs b/src/kwp2000/errors.rs index 374acfa..be08045 100644 --- a/src/kwp2000/errors.rs +++ b/src/kwp2000/errors.rs @@ -4,6 +4,7 @@ crate::utils::enum_wrapper!(kwp2000, KwpError, KwpErrorByte); #[repr(u8)] #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum KwpError { /// ECU rejected the request for unknown reason GeneralReject = 0x10, diff --git a/src/kwp2000/reset_types.rs b/src/kwp2000/reset_types.rs index 285c79a..f900096 100644 --- a/src/kwp2000/reset_types.rs +++ b/src/kwp2000/reset_types.rs @@ -14,6 +14,7 @@ crate::utils::enum_wrapper!(kwp2000, ResetType, ResetTypeByte); #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] #[cfg_attr(feature = "display", derive(displaydoc::Display))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum ResetType { /// Simulates a power off/on reset of the ECU. PowerOnReset = 0x01, diff --git a/src/kwp2000/routine_exit_status.rs b/src/kwp2000/routine_exit_status.rs index 49ed622..6aa56c3 100644 --- a/src/kwp2000/routine_exit_status.rs +++ b/src/kwp2000/routine_exit_status.rs @@ -3,6 +3,7 @@ crate::utils::enum_wrapper!(kwp2000, RoutineExitStatus, RoutineExitStatusByte); #[repr(u8)] #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum RoutineExitStatus { /// Normal exit with results available NormalExitWithResults = 0x61, diff --git a/src/kwp2000/session_types.rs b/src/kwp2000/session_types.rs index 900d746..60ff719 100644 --- a/src/kwp2000/session_types.rs +++ b/src/kwp2000/session_types.rs @@ -14,6 +14,7 @@ crate::utils::enum_wrapper!(kwp2000, KwpSessionType, KwpSessionTypeByte); #[repr(u8)] #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum KwpSessionType { /// Normal session. The ECU will typically boot in this state. /// In this mode, only non-intrusive functions are supported. diff --git a/src/obd2/command_2nd_air_status.rs b/src/obd2/command_2nd_air_status.rs index 7f346fd..086a3f9 100644 --- a/src/obd2/command_2nd_air_status.rs +++ b/src/obd2/command_2nd_air_status.rs @@ -9,6 +9,7 @@ crate::utils::enum_wrapper!( #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] #[cfg_attr(feature = "display", derive(displaydoc::Display))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum CommandedSecondaryAirStatus { /// Upstream Upstream = 0x01, diff --git a/src/obd2/commands.rs b/src/obd2/commands.rs index d7fef62..abc15f5 100644 --- a/src/obd2/commands.rs +++ b/src/obd2/commands.rs @@ -5,6 +5,7 @@ crate::utils::enum_wrapper!(obd2, Obd2Command, Obd2CommandByte); #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] #[cfg_attr(feature = "display", derive(displaydoc::Display))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Obd2Command { /// Service 01 - Show current data Service01 = 0x01, diff --git a/src/obd2/data_pids.rs b/src/obd2/data_pids.rs index 9c706c2..7600a5c 100644 --- a/src/obd2/data_pids.rs +++ b/src/obd2/data_pids.rs @@ -4,6 +4,7 @@ crate::utils::enum_wrapper!(obd2, DataPid, DataPidByte); #[repr(u8)] #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum DataPid { PidSupport0120 = 0x00, StatusSinceDTCCleared = 0x01, diff --git a/src/obd2/errors.rs b/src/obd2/errors.rs index f29f2ce..f37bfd5 100644 --- a/src/obd2/errors.rs +++ b/src/obd2/errors.rs @@ -5,6 +5,7 @@ crate::utils::enum_wrapper!(obd2, Obd2Error, Obd2ErrorByte); #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] #[cfg_attr(feature = "display", derive(displaydoc::Display))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Obd2Error { /// ECU general reject GeneralReject = 0x10, diff --git a/src/obd2/fuel_system_status.rs b/src/obd2/fuel_system_status.rs index d86dbed..1fceac2 100644 --- a/src/obd2/fuel_system_status.rs +++ b/src/obd2/fuel_system_status.rs @@ -5,6 +5,7 @@ crate::utils::enum_wrapper!(obd2, FuelSystemStatus, FuelSystemStatusByte); #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] #[cfg_attr(feature = "display", derive(displaydoc::Display))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum FuelSystemStatus { /// The motor is off Off = 0x00, diff --git a/src/obd2/fuel_types.rs b/src/obd2/fuel_types.rs index beddd93..d0d1284 100644 --- a/src/obd2/fuel_types.rs +++ b/src/obd2/fuel_types.rs @@ -6,6 +6,7 @@ crate::utils::enum_wrapper!(obd2, FuelTypeCoding, FuelTypeCodingByte); #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] #[cfg_attr(feature = "display", derive(displaydoc::Display))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum FuelTypeCoding { /// Fuel type unavailable NotAvailable = 0, diff --git a/src/obd2/obd_standard.rs b/src/obd2/obd_standard.rs index 78e70bf..69d8a02 100644 --- a/src/obd2/obd_standard.rs +++ b/src/obd2/obd_standard.rs @@ -6,6 +6,7 @@ crate::utils::enum_wrapper!(obd2, ObdStandard, ObdStandardByte); #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] #[cfg_attr(feature = "display", derive(displaydoc::Display))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[allow(clippy::doc_markdown)] pub enum ObdStandard { /// OBD-II as defined by the CARB diff --git a/src/obd2/service09.rs b/src/obd2/service09.rs index 55e19e1..41bcd8e 100644 --- a/src/obd2/service09.rs +++ b/src/obd2/service09.rs @@ -5,6 +5,7 @@ crate::utils::enum_wrapper!(obd2, Service09Pid, Service09PidByte); #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] #[cfg_attr(feature = "display", derive(displaydoc::Display))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Service09Pid { /// VIN message count (Only for LIN) VinMsgCount = 0x01, diff --git a/src/uds/comm_level.rs b/src/uds/comm_level.rs index 090d83a..38f06de 100644 --- a/src/uds/comm_level.rs +++ b/src/uds/comm_level.rs @@ -4,6 +4,7 @@ crate::utils::enum_wrapper!(uds, CommunicationLevel, CommunicationLevelByte); #[repr(u8)] #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum CommunicationLevel { /// This value indicates that the reception and transmission of messages /// shall be enabled for the specified communicationType. diff --git a/src/uds/commands.rs b/src/uds/commands.rs index 7dce9a0..4e0afab 100644 --- a/src/uds/commands.rs +++ b/src/uds/commands.rs @@ -5,6 +5,7 @@ crate::utils::enum_wrapper!(uds, UdsCommand, UdsCommandByte); #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] #[cfg_attr(feature = "display", derive(displaydoc::Display))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum UdsCommand { /// The client requests to control a diagnostic session with a server(s). DiagnosticSessionControl = 0x10, @@ -59,3 +60,30 @@ pub enum UdsCommand { /// The client requests the negotiation of a file transfer between server and client. RequestFileTransfer = 0x38, } + +#[cfg(all(test, feature = "serde"))] +mod tests { + use super::*; + + #[derive(serde::Serialize, serde::Deserialize)] + struct TestStruct { + command: UdsCommand, + command_byte: UdsCommandByte, + } + + #[test] + fn test_serde() { + let test = TestStruct { + command: UdsCommand::DiagnosticSessionControl, + command_byte: UdsCommandByte::from(UdsCommand::DiagnosticSessionControl), + }; + + let json = serde_json::to_string(&test).unwrap(); + insta::assert_snapshot!(json, @r###"{"command":"DiagnosticSessionControl","command_byte":{"Standard":"DiagnosticSessionControl"}}"###); + + let deserialized: TestStruct = serde_json::from_str(&json).unwrap(); + + assert_eq!(test.command, deserialized.command); + assert_eq!(test.command_byte, deserialized.command_byte); + } +} diff --git a/src/uds/errors.rs b/src/uds/errors.rs index 64deaae..a287955 100644 --- a/src/uds/errors.rs +++ b/src/uds/errors.rs @@ -8,6 +8,7 @@ enum_wrapper!(uds, UdsError, UdsErrorByte); #[repr(u8)] #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum UdsError { /// ECU rejected the request (No specific error) GeneralReject = 0x10, diff --git a/src/uds/read_dtc_information.rs b/src/uds/read_dtc_information.rs index bea0d69..a83d313 100644 --- a/src/uds/read_dtc_information.rs +++ b/src/uds/read_dtc_information.rs @@ -9,6 +9,7 @@ enum_wrapper!(uds, DtcSubFunction, DtcSubFunctionByte); #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] #[cfg_attr(feature = "display", derive(displaydoc::Display))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[allow(clippy::doc_markdown)] pub enum DtcSubFunction { /// This function takes a 1 byte DTCStatusMask diff --git a/src/uds/reset_types.rs b/src/uds/reset_types.rs index 2de9ab9..07d57a1 100644 --- a/src/uds/reset_types.rs +++ b/src/uds/reset_types.rs @@ -4,6 +4,7 @@ crate::utils::enum_wrapper!(uds, ResetType, ResetTypeByte); #[repr(u8)] #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum ResetType { /// Signals the ECU to perform a hard-reset, /// simulating a forceful power off/on cycle diff --git a/src/uds/routine.rs b/src/uds/routine.rs index ccea44d..e3907b1 100644 --- a/src/uds/routine.rs +++ b/src/uds/routine.rs @@ -5,6 +5,7 @@ crate::utils::enum_wrapper!(uds, RoutineControlType, RoutineControlTypeByte); #[repr(u8)] #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum RoutineControlType { /// Launches a routine on the ECU StartRoutine = 0x01, diff --git a/src/uds/scaling_byte.rs b/src/uds/scaling_byte.rs index 03a0255..b72498e 100644 --- a/src/uds/scaling_byte.rs +++ b/src/uds/scaling_byte.rs @@ -6,6 +6,7 @@ crate::utils::enum_impls!(uds, ScalingType); #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] #[cfg_attr(feature = "display", derive(displaydoc::Display))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum ScalingType { /// Unsigned numeric integer. Must be followed by 1..4 bytes, given as a low nibble of the byte. UnsignedNumeric = 0x00, diff --git a/src/uds/scaling_byte_ext.rs b/src/uds/scaling_byte_ext.rs index a55816e..a3b41ea 100644 --- a/src/uds/scaling_byte_ext.rs +++ b/src/uds/scaling_byte_ext.rs @@ -63,7 +63,8 @@ generate_enum! { /// or [`ScalingExtension::get_prefix`] to return the optional prefix of the scaling byte. #[repr(u8)] #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(feature = "iter", derive(strum::EnumIter))] + #[cfg_attr(feature = "iter", derive(strum::EnumIter))] + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum ScalingExtension { /// No unit or presentation NoUnit = 0x00, diff --git a/src/uds/security_access.rs b/src/uds/security_access.rs index adc7002..6497a2b 100644 --- a/src/uds/security_access.rs +++ b/src/uds/security_access.rs @@ -9,6 +9,7 @@ crate::utils::enum_wrapper!(uds, SecurityOperation, SecurityOperationByte); #[repr(u8)] #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum SecurityOperation { /// Asks the ECU for a security seed RequestSeed = 0x01, diff --git a/src/uds/session_types.rs b/src/uds/session_types.rs index a8f8003..c699af9 100644 --- a/src/uds/session_types.rs +++ b/src/uds/session_types.rs @@ -4,6 +4,7 @@ crate::utils::enum_wrapper!(uds, UdsSessionType, UdsSessionTypeByte); #[repr(u8)] #[derive(strum::FromRepr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "iter", derive(strum::EnumIter))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum UdsSessionType { /// Default diagnostic session mode (ECU is normally in this mode on startup) /// This session type does not require the diagnostic server to sent `TesterPresent` messages diff --git a/src/utils.rs b/src/utils.rs index e75b093..e50b406 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -3,6 +3,7 @@ use core::fmt::Debug; /// A wrapper around a byte, which can be either an ISO-standardized value for a specific enum, /// or an implementation-specific/invalid `Extended` value wrapping original byte. #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum ByteWrapper { Standard(T), Extended(u8), From 4c8d1e2ef81b16bcdac77e34311506c975b3a710 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Mon, 1 Jul 2024 13:40:39 +0300 Subject: [PATCH 2/5] add serde testing, make it opt --- Cargo.toml | 3 +-- justfile | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a21a41b..70f0197 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,12 +29,11 @@ serde = ["dep:serde"] [dependencies] displaydoc = { version = "0.2", optional = true } +serde = { version = "1", features = ["derive"], optional = true } strum = { version = "0.26.3", features = ["derive"] } -serde = { version = "1", optional = true } [dev-dependencies] cargo-husky = { version = "1", features = ["user-hooks"], default-features = false } -serde = { version = "1", features = ["derive"] } serde_json = { version = "1", features = ["preserve_order"] } insta = { version = "1.39" } diff --git a/justfile b/justfile index 0cff86f..26714d4 100644 --- a/justfile +++ b/justfile @@ -34,6 +34,7 @@ check: # Run all tests test: RUSTFLAGS='-D warnings' cargo test + RUSTFLAGS='-D warnings' cargo test --features serde RUSTFLAGS='-D warnings' cargo test --no-default-features --features with-kwp2000 RUSTFLAGS='-D warnings' cargo test --no-default-features --features with-obd2 RUSTFLAGS='-D warnings' cargo test --no-default-features --features with-uds From a4642a07534970f5dc3eb3365b811b305d925365 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Mon, 1 Jul 2024 13:45:50 +0300 Subject: [PATCH 3/5] rm insta --- Cargo.toml | 1 - src/uds/commands.rs | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 70f0197..95cdd85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,6 @@ strum = { version = "0.26.3", features = ["derive"] } [dev-dependencies] cargo-husky = { version = "1", features = ["user-hooks"], default-features = false } serde_json = { version = "1", features = ["preserve_order"] } -insta = { version = "1.39" } [lints.rust] unsafe_code = "forbid" diff --git a/src/uds/commands.rs b/src/uds/commands.rs index 4e0afab..154f2aa 100644 --- a/src/uds/commands.rs +++ b/src/uds/commands.rs @@ -79,7 +79,10 @@ mod tests { }; let json = serde_json::to_string(&test).unwrap(); - insta::assert_snapshot!(json, @r###"{"command":"DiagnosticSessionControl","command_byte":{"Standard":"DiagnosticSessionControl"}}"###); + assert_eq!( + json, + r###"{"command":"DiagnosticSessionControl","command_byte":{"Standard":"DiagnosticSessionControl"}}"### + ); let deserialized: TestStruct = serde_json::from_str(&json).unwrap(); From cc417b1ee931d6891568b6238d34edaca79d23c1 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Mon, 1 Jul 2024 14:11:22 +0300 Subject: [PATCH 4/5] fix msrv --- justfile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/justfile b/justfile index 26714d4..978a682 100644 --- a/justfile +++ b/justfile @@ -32,13 +32,17 @@ check: # Run all tests -test: - RUSTFLAGS='-D warnings' cargo test +test: test-no-serde RUSTFLAGS='-D warnings' cargo test --features serde + +# Test with no serde support because it requires newer Rust versions +test-no-serde: + RUSTFLAGS='-D warnings' cargo test RUSTFLAGS='-D warnings' cargo test --no-default-features --features with-kwp2000 RUSTFLAGS='-D warnings' cargo test --no-default-features --features with-obd2 RUSTFLAGS='-D warnings' cargo test --no-default-features --features with-uds + # Test documentation test-doc: cargo test --doc @@ -52,4 +56,4 @@ rust-info: ci-test: rust-info test-fmt clippy check test test-doc # Run minimal subset of tests to ensure compatibility with MSRV -ci-test-msrv: rust-info check test +ci-test-msrv: rust-info check test-no-serde From c020fced17d63b91df70a45c3aa10a6ff2e0a4fc Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Mon, 1 Jul 2024 14:17:08 +0300 Subject: [PATCH 5/5] serde --- Cargo.toml | 2 +- justfile | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 95cdd85..489c290 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" license = "MIT OR Apache-2.0" keywords = ["uds", "kwp2000", "obd", "automotive", "no_std"] categories = ["embedded", "no-std", "encoding", "parsing"] -rust-version = "1.61.0" +rust-version = "1.63.0" [features] default = ["std", "iter", "display", "with-kwp2000", "with-obd2", "with-uds"] diff --git a/justfile b/justfile index 978a682..26a2e68 100644 --- a/justfile +++ b/justfile @@ -32,16 +32,12 @@ check: # Run all tests -test: test-no-serde - RUSTFLAGS='-D warnings' cargo test --features serde - -# Test with no serde support because it requires newer Rust versions -test-no-serde: +test: RUSTFLAGS='-D warnings' cargo test RUSTFLAGS='-D warnings' cargo test --no-default-features --features with-kwp2000 RUSTFLAGS='-D warnings' cargo test --no-default-features --features with-obd2 RUSTFLAGS='-D warnings' cargo test --no-default-features --features with-uds - + RUSTFLAGS='-D warnings' cargo test --features serde # Test documentation test-doc: @@ -56,4 +52,4 @@ rust-info: ci-test: rust-info test-fmt clippy check test test-doc # Run minimal subset of tests to ensure compatibility with MSRV -ci-test-msrv: rust-info check test-no-serde +ci-test-msrv: rust-info check test