Remove EppObject wrapper where unnecessary
This was being used in a few places where it was unnecessary. Interestingly, it seemed that the deserialization logic in `Request::deserialize_response()` was nesting `EppObject`s without actually causing an error.
This commit is contained in:
parent
627b7d3e23
commit
37feb5c2c4
|
@ -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<Response<EppObject<ResponseStatus>, NoExtension>, error::Error> {
|
||||
pub async fn logout(&mut self) -> Result<Response<ResponseStatus, NoExtension>, error::Error> {
|
||||
let client_tr_id = generate_client_tr_id(&self.credentials.0).unwrap();
|
||||
let epp_logout = Logout::<NoExtension>::new();
|
||||
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -39,12 +39,10 @@ pub trait EppRequest<E: EppExtension>: Sized + Debug {
|
|||
let rsp = <EppObject<Response<Self::Output, E::Response>> as EppXml>::deserialize(epp_xml)?;
|
||||
match rsp.data.result.code {
|
||||
0..=2000 => Ok(rsp.data),
|
||||
_ => Err(crate::error::Error::EppCommandError(EppObject::build(
|
||||
ResponseStatus {
|
||||
_ => Err(crate::error::Error::EppCommandError(ResponseStatus {
|
||||
result: rsp.data.result,
|
||||
tr_ids: rsp.data.tr_ids,
|
||||
},
|
||||
))),
|
||||
})),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ResponseStatus>;
|
||||
pub type EppCommandResponse = ResponseStatus;
|
||||
|
||||
/// Type corresponding to the <undef> tag an EPP response XML
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
|
|
|
@ -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::<ResponseStatus>::deserialize(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.data.result.code, 2303);
|
||||
assert_eq!(object.data.result.message, "Object does not exist".into());
|
||||
|
|
Loading…
Reference in New Issue