From b9b80656c78aa3b4cef61a2b0902ae6040ffdced Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Wed, 27 Mar 2024 12:12:53 +0100 Subject: [PATCH] Simplify naming of ProtocolError variants (#255) Easier to distinguish if they don't start with the same prefix. --- src/error.rs | 4 ++-- src/service/rtu.rs | 4 ++-- src/service/tcp.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/error.rs b/src/error.rs index a11cca1..4f340a8 100644 --- a/src/error.rs +++ b/src/error.rs @@ -28,7 +28,7 @@ pub enum ProtocolError { /// /// The result received from the server is included for further analysis and handling. #[error("mismatching headers: {message} {result:?}")] - MismatchingHeaders { + HeaderMismatch { message: String, result: Result, }, @@ -37,7 +37,7 @@ pub enum ProtocolError { /// /// The result received from the server is included for further analysis and handling. #[error("mismatching function codes: {request} {result:?}")] - MismatchingFunctionCodes { + FunctionCodeMismatch { request: FunctionCode, result: Result, }, diff --git a/src/service/rtu.rs b/src/service/rtu.rs index db5e5da..239c379 100644 --- a/src/service/rtu.rs +++ b/src/service/rtu.rs @@ -66,7 +66,7 @@ where // Match headers of request and response. if let Err(message) = verify_response_header(&req_hdr, &res_adu.hdr) { - return Err(ProtocolError::MismatchingHeaders { message, result }.into()); + return Err(ProtocolError::HeaderMismatch { message, result }.into()); } // Match function codes of request and response. @@ -75,7 +75,7 @@ where Err(ExceptionResponse { function, .. }) => *function, }; if req_function_code != rsp_function_code { - return Err(ProtocolError::MismatchingFunctionCodes { + return Err(ProtocolError::FunctionCodeMismatch { request: req_function_code, result, } diff --git a/src/service/tcp.rs b/src/service/tcp.rs index 043ca94..1934886 100644 --- a/src/service/tcp.rs +++ b/src/service/tcp.rs @@ -89,7 +89,7 @@ where // Match headers of request and response. if let Err(message) = verify_response_header(&req_hdr, &res_adu.hdr) { - return Err(ProtocolError::MismatchingHeaders { message, result }.into()); + return Err(ProtocolError::HeaderMismatch { message, result }.into()); } // Match function codes of request and response. @@ -98,7 +98,7 @@ where Err(ExceptionResponse { function, .. }) => *function, }; if req_function_code != rsp_function_code { - return Err(ProtocolError::MismatchingFunctionCodes { + return Err(ProtocolError::FunctionCodeMismatch { request: req_function_code, result, }