From 91070576cdf244ef48eb1acceac59c886180866d Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 2 Dec 2021 13:42:56 +0100 Subject: [PATCH] Remove EppCommandResponseError alias This is a direct alias for EppCommandResponse. It is documented as marking an error state, but type aliases aren't a great tool for that because the type system doesn't distinguish aliased types; if we want to do that seriously it should be a newtype wrapper. --- epp-client/src/error.rs | 6 +++--- epp-client/src/response.rs | 2 -- epp-client/src/tests/de.rs | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/epp-client/src/error.rs b/epp-client/src/error.rs index c0e4179..c4402c5 100644 --- a/epp-client/src/error.rs +++ b/epp-client/src/error.rs @@ -1,13 +1,13 @@ //! Error types to wrap internal errors and make EPP errors easier to read -use crate::response::EppCommandResponseError; +use crate::response::EppCommandResponse; use std::fmt::Display; /// Error enum holding the possible error types #[derive(Debug)] pub enum Error { EppConnectionError(std::io::Error), - EppCommandError(EppCommandResponseError), + EppCommandError(EppCommandResponse), EppDeserializationError(String), Other(String), } @@ -15,7 +15,7 @@ pub enum Error { /// An EPP XML error #[derive(Debug)] pub struct EppCommandError { - pub epp_error: EppCommandResponseError, + pub epp_error: EppCommandResponse, } impl std::error::Error for Error {} diff --git a/epp-client/src/response.rs b/epp-client/src/response.rs index 43abb98..422e785 100644 --- a/epp-client/src/response.rs +++ b/epp-client/src/response.rs @@ -8,8 +8,6 @@ use crate::common::{ElementName, EppObject, Extension, StringValue}; /// A generic EPP Response to an EPP command with a result section, a status code and a message pub type EppCommandResponse = EppObject; -/// An alias of `EppCommandResponse` indicating an EPP Error -pub type EppCommandResponseError = EppCommandResponse; /// Type corresponding to the tag an EPP response XML #[derive(Serialize, Deserialize, Debug, PartialEq)] diff --git a/epp-client/src/tests/de.rs b/epp-client/src/tests/de.rs index 7a6eb31..5b15b03 100644 --- a/epp-client/src/tests/de.rs +++ b/epp-client/src/tests/de.rs @@ -35,7 +35,7 @@ mod response { use crate::message::ack::MessageAck; use crate::message::poll::MessagePoll; use crate::request::EppRequest; - use crate::response::EppCommandResponseError; + use crate::response::EppCommandResponse; use crate::xml::EppXml; const SVTRID: &str = "RO-6879-1627224678242975"; @@ -75,7 +75,7 @@ mod response { #[test] fn error() { let xml = get_xml("response/error.xml").unwrap(); - let object = EppCommandResponseError::deserialize(xml.as_str()).unwrap(); + let object = EppCommandResponse::deserialize(xml.as_str()).unwrap(); assert_eq!(object.data.result.code, 2303); assert_eq!(object.data.result.message, "Object does not exist".into());