diff --git a/epp-client/src/client.rs b/epp-client/src/client.rs index 9436819..f8df41c 100644 --- a/epp-client/src/client.rs +++ b/epp-client/src/client.rs @@ -50,7 +50,7 @@ use std::time::SystemTime; use std::{error::Error, fmt::Debug}; -use crate::common::{EppObject, NoExtension}; +use crate::common::NoExtension; use crate::config::EppClientConfig; use crate::error; use crate::hello::{Greeting, Hello}; @@ -177,9 +177,7 @@ impl EppClient { } /// Sends the EPP Logout command to log out of the EPP session - pub async fn logout( - &mut self, - ) -> Result, NoExtension>, error::Error> { + pub async fn logout(&mut self) -> Result, error::Error> { let client_tr_id = generate_client_tr_id(&self.credentials.0).unwrap(); let epp_logout = Logout::::new(); diff --git a/epp-client/src/error.rs b/epp-client/src/error.rs index c4402c5..0cf64f2 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::EppCommandResponse; +use crate::response::ResponseStatus; use std::fmt::Display; /// Error enum holding the possible error types #[derive(Debug)] pub enum Error { EppConnectionError(std::io::Error), - EppCommandError(EppCommandResponse), + EppCommandError(ResponseStatus), EppDeserializationError(String), Other(String), } @@ -15,7 +15,7 @@ pub enum Error { /// An EPP XML error #[derive(Debug)] pub struct EppCommandError { - pub epp_error: EppCommandResponse, + pub epp_error: ResponseStatus, } impl std::error::Error for Error {} @@ -24,7 +24,7 @@ impl Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Error::EppCommandError(e) => { - write!(f, "epp-client EppCommandError: {}", e.data.result.message) + write!(f, "epp-client EppCommandError: {}", e.result.message) } Error::Other(e) => write!(f, "epp-client Exception: {}", e), _ => write!(f, "epp-client Exception: {:?}", self), diff --git a/epp-client/src/request.rs b/epp-client/src/request.rs index a89effe..abe6d9e 100644 --- a/epp-client/src/request.rs +++ b/epp-client/src/request.rs @@ -39,12 +39,10 @@ pub trait EppRequest: Sized + Debug { let rsp = > as EppXml>::deserialize(epp_xml)?; match rsp.data.result.code { 0..=2000 => Ok(rsp.data), - _ => Err(crate::error::Error::EppCommandError(EppObject::build( - ResponseStatus { - result: rsp.data.result, - tr_ids: rsp.data.tr_ids, - }, - ))), + _ => Err(crate::error::Error::EppCommandError(ResponseStatus { + result: rsp.data.result, + tr_ids: rsp.data.tr_ids, + })), } } } diff --git a/epp-client/src/response.rs b/epp-client/src/response.rs index 0665df8..e83dc62 100644 --- a/epp-client/src/response.rs +++ b/epp-client/src/response.rs @@ -4,10 +4,10 @@ use epp_client_macros::*; use serde::{Deserialize, Serialize}; use std::fmt::Debug; -use crate::common::{ElementName, EppObject, Extension, StringValue}; +use crate::common::{ElementName, Extension, StringValue}; /// A generic EPP Response to an EPP command with a result section, a status code and a message -pub type EppCommandResponse = EppObject; +pub type EppCommandResponse = ResponseStatus; /// 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 5b15b03..90c9204 100644 --- a/epp-client/src/tests/de.rs +++ b/epp-client/src/tests/de.rs @@ -3,7 +3,7 @@ mod response { use super::super::get_xml; use super::super::CLTRID; - use crate::common::NoExtension; + use crate::common::{EppObject, NoExtension}; use crate::contact::check::ContactCheck; use crate::contact::create::ContactCreate; use crate::contact::delete::ContactDelete; @@ -35,7 +35,7 @@ mod response { use crate::message::ack::MessageAck; use crate::message::poll::MessagePoll; use crate::request::EppRequest; - use crate::response::EppCommandResponse; + use crate::response::ResponseStatus; 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 = EppCommandResponse::deserialize(xml.as_str()).unwrap(); + let object = EppObject::::deserialize(xml.as_str()).unwrap(); assert_eq!(object.data.result.code, 2303); assert_eq!(object.data.result.message, "Object does not exist".into());