diff --git a/README.md b/README.md index 48e6b2f..eed6802 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ use std::collections::HashMap; use epp_client::config::{EppClientConfig, EppClientConnection}; use epp_client::EppClient; use epp_client::epp::{EppDomainCheck, EppDomainCheckResponse}; -use epp_client::epp::generate_client_tr_id; +use epp_client::generate_client_tr_id; #[tokio::main] async fn main() { diff --git a/epp-client/README.md b/epp-client/README.md index 48e6b2f..eed6802 100644 --- a/epp-client/README.md +++ b/epp-client/README.md @@ -56,7 +56,7 @@ use std::collections::HashMap; use epp_client::config::{EppClientConfig, EppClientConnection}; use epp_client::EppClient; use epp_client::epp::{EppDomainCheck, EppDomainCheckResponse}; -use epp_client::epp::generate_client_tr_id; +use epp_client::generate_client_tr_id; #[tokio::main] async fn main() { diff --git a/epp-client/src/connection/client.rs b/epp-client/src/connection/client.rs index 60d3200..9980dd4 100644 --- a/epp-client/src/connection/client.rs +++ b/epp-client/src/connection/client.rs @@ -8,7 +8,7 @@ //! use epp_client::config::{EppClientConfig, EppClientConnection}; //! use epp_client::EppClient; //! use epp_client::domain::check::{EppDomainCheck, EppDomainCheckResponse}; -//! use epp_client::epp::generate_client_tr_id; +//! use epp_client::generate_client_tr_id; //! //! #[tokio::main] //! async fn main() { @@ -51,12 +51,12 @@ use std::{error::Error, fmt::Debug}; use crate::config::EppClientConfig; use crate::connection::registry::{epp_connect, EppConnection}; -use crate::epp::xml::EppXml; use crate::error; use crate::request::{generate_client_tr_id, EppHello, EppLogin, EppLogout}; use crate::response::{ EppCommandResponse, EppCommandResponseError, EppGreeting, EppLoginResponse, EppLogoutResponse, }; +use crate::xml::EppXml; /// Instances of the EppClient type are used to transact with the registry. /// Once initialized, the EppClient instance can serialize EPP requests to XML and send them /// to the registry and deserialize the XML responses from the registry to local types diff --git a/epp-client/src/contact.rs b/epp-client/src/contact.rs index 035f812..f00d130 100644 --- a/epp-client/src/contact.rs +++ b/epp-client/src/contact.rs @@ -3,3 +3,5 @@ pub mod create; pub mod delete; pub mod info; pub mod update; + +pub const EPP_CONTACT_XMLNS: &str = "urn:ietf:params:xml:ns:contact-1.0"; diff --git a/epp-client/src/contact/check.rs b/epp-client/src/contact/check.rs index 00b3e18..b769dc0 100644 --- a/epp-client/src/contact/check.rs +++ b/epp-client/src/contact/check.rs @@ -2,9 +2,9 @@ use epp_client_macros::*; use crate::common::{ElementName, EppObject, StringValue}; +use crate::contact::EPP_CONTACT_XMLNS; use crate::request::Command; use crate::response::CommandResponse; -use crate::epp::xml::EPP_CONTACT_XMLNS; use serde::{Deserialize, Serialize}; /// Type that represents the <epp> request for contact <check> command @@ -17,7 +17,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::contact::check::{EppContactCheck, EppContactCheckResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { diff --git a/epp-client/src/contact/create.rs b/epp-client/src/contact/create.rs index 235de3d..861421c 100644 --- a/epp-client/src/contact/create.rs +++ b/epp-client/src/contact/create.rs @@ -3,7 +3,7 @@ use epp_client_macros::*; use crate::common::{ContactAuthInfo, ElementName, EppObject, Phone, PostalInfo, StringValue}; -use crate::epp::xml::EPP_CONTACT_XMLNS; +use crate::contact::EPP_CONTACT_XMLNS; use crate::request::Command; use crate::response::CommandResponse; use serde::{Deserialize, Serialize}; @@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::EppClient; /// use epp_client::common::{Address, Phone, PostalInfo}; /// use epp_client::contact::create::{EppContactCreate, EppContactCreateResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { diff --git a/epp-client/src/contact/delete.rs b/epp-client/src/contact/delete.rs index 4d7c4a0..37af308 100644 --- a/epp-client/src/contact/delete.rs +++ b/epp-client/src/contact/delete.rs @@ -3,7 +3,7 @@ use epp_client_macros::*; use crate::common::{ElementName, EppObject, StringValue}; -use crate::epp::xml::EPP_CONTACT_XMLNS; +use crate::contact::EPP_CONTACT_XMLNS; use crate::request::Command; use crate::response::EppCommandResponse; use serde::{Deserialize, Serialize}; @@ -18,7 +18,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::contact::delete::{EppContactDelete, EppContactDeleteResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { diff --git a/epp-client/src/contact/info.rs b/epp-client/src/contact/info.rs index af3566f..555e144 100644 --- a/epp-client/src/contact/info.rs +++ b/epp-client/src/contact/info.rs @@ -5,7 +5,7 @@ use epp_client_macros::*; use crate::common::{ ContactAuthInfo, ContactStatus, ElementName, EppObject, Phone, PostalInfo, StringValue, }; -use crate::epp::xml::EPP_CONTACT_XMLNS; +use crate::contact::EPP_CONTACT_XMLNS; use crate::request::Command; use crate::response::CommandResponse; use serde::{Deserialize, Serialize}; @@ -20,7 +20,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::contact::info::{EppContactInfo, EppContactInfoResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { diff --git a/epp-client/src/contact/update.rs b/epp-client/src/contact/update.rs index 4d11ec2..219584a 100644 --- a/epp-client/src/contact/update.rs +++ b/epp-client/src/contact/update.rs @@ -6,7 +6,7 @@ use crate::common::{ ContactAuthInfo, ContactStatus, ElementName, EppObject, Phone, PostalInfo, StringValue, }; use crate::contact::info::EppContactInfoResponse; -use crate::epp::xml::EPP_CONTACT_XMLNS; +use crate::contact::EPP_CONTACT_XMLNS; use crate::error; use crate::request::Command; use crate::response::EppCommandResponse; @@ -22,7 +22,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::contact::update::{EppContactUpdate, EppContactUpdateResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// use epp_client::common::ContactStatus; /// /// #[tokio::main] diff --git a/epp-client/src/domain.rs b/epp-client/src/domain.rs index 6c80ad8..8c259a5 100644 --- a/epp-client/src/domain.rs +++ b/epp-client/src/domain.rs @@ -6,3 +6,5 @@ pub mod renew; pub mod rgp; pub mod transfer; pub mod update; + +pub const EPP_DOMAIN_XMLNS: &str = "urn:ietf:params:xml:ns:domain-1.0"; diff --git a/epp-client/src/domain/check.rs b/epp-client/src/domain/check.rs index 4cc3ff4..9719bed 100644 --- a/epp-client/src/domain/check.rs +++ b/epp-client/src/domain/check.rs @@ -2,8 +2,8 @@ use epp_client_macros::*; +use super::EPP_DOMAIN_XMLNS; use crate::common::{ElementName, EppObject, StringValue}; -use crate::epp::xml::EPP_DOMAIN_XMLNS; use crate::request::Command; use crate::response::CommandResponse; use serde::{Deserialize, Serialize}; @@ -18,7 +18,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::domain::check::{EppDomainCheck, EppDomainCheckResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { diff --git a/epp-client/src/domain/create.rs b/epp-client/src/domain/create.rs index 8ede09c..4d8bf73 100644 --- a/epp-client/src/domain/create.rs +++ b/epp-client/src/domain/create.rs @@ -2,11 +2,11 @@ use epp_client_macros::*; +use super::EPP_DOMAIN_XMLNS; use crate::common::{ DomainAuthInfo, DomainContact, ElementName, EppObject, HostAttr, HostAttrList, HostList, HostObjList, Period, StringValue, }; -use crate::epp::xml::EPP_DOMAIN_XMLNS; use crate::request::Command; use crate::response::CommandResponse; use serde::{Deserialize, Serialize}; @@ -23,7 +23,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::EppClient; /// use epp_client::common::DomainContact; /// use epp_client::domain::create::{EppDomainCreate, EppDomainCreateResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { diff --git a/epp-client/src/domain/delete.rs b/epp-client/src/domain/delete.rs index 5547198..f665d64 100644 --- a/epp-client/src/domain/delete.rs +++ b/epp-client/src/domain/delete.rs @@ -2,8 +2,8 @@ use epp_client_macros::*; +use super::EPP_DOMAIN_XMLNS; use crate::common::{ElementName, EppObject, StringValue}; -use crate::epp::xml::EPP_DOMAIN_XMLNS; use crate::request::Command; use crate::response::EppCommandResponse; use serde::{Deserialize, Serialize}; @@ -18,7 +18,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::domain::delete::{EppDomainDelete, EppDomainDeleteResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { diff --git a/epp-client/src/domain/info.rs b/epp-client/src/domain/info.rs index 72dd591..0546abe 100644 --- a/epp-client/src/domain/info.rs +++ b/epp-client/src/domain/info.rs @@ -2,11 +2,11 @@ use epp_client_macros::*; +use super::EPP_DOMAIN_XMLNS; use crate::common::{ DomainAuthInfo, DomainContact, DomainStatus, ElementName, EppObject, HostAttr, StringValue, }; use crate::domain::rgp::request::RgpRequestResponse; -use crate::epp::xml::EPP_DOMAIN_XMLNS; use crate::request::Command; use crate::response::CommandResponseWithExtension; use serde::{Deserialize, Serialize}; @@ -21,7 +21,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::domain::info::{EppDomainInfo, EppDomainInfoResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { diff --git a/epp-client/src/domain/renew.rs b/epp-client/src/domain/renew.rs index 4717e05..333edb9 100644 --- a/epp-client/src/domain/renew.rs +++ b/epp-client/src/domain/renew.rs @@ -2,8 +2,8 @@ use epp_client_macros::*; +use super::EPP_DOMAIN_XMLNS; use crate::common::{ElementName, EppObject, Period, StringValue}; -use crate::epp::xml::EPP_DOMAIN_XMLNS; use crate::request::Command; use crate::response::CommandResponse; use chrono::NaiveDate; @@ -21,7 +21,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::domain::renew::{EppDomainRenew, EppDomainRenewResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { diff --git a/epp-client/src/domain/rgp.rs b/epp-client/src/domain/rgp.rs index 8775fb4..708b874 100644 --- a/epp-client/src/domain/rgp.rs +++ b/epp-client/src/domain/rgp.rs @@ -2,3 +2,5 @@ pub mod report; pub mod request; + +pub const EPP_DOMAIN_RGP_EXT_XMLNS: &str = "urn:ietf:params:xml:ns:rgp-1.0"; diff --git a/epp-client/src/domain/rgp/report.rs b/epp-client/src/domain/rgp/report.rs index 7f11522..0e9f9d4 100644 --- a/epp-client/src/domain/rgp/report.rs +++ b/epp-client/src/domain/rgp/report.rs @@ -3,8 +3,9 @@ use epp_client_macros::*; use crate::common::{ElementName, EppObject, Extension, StringValue}; +use crate::domain::rgp::EPP_DOMAIN_RGP_EXT_XMLNS; use crate::domain::update::{DomainChangeInfo, DomainUpdateRequest, DomainUpdateRequestData}; -use crate::epp::xml::{EPP_DOMAIN_RGP_EXT_XMLNS, EPP_DOMAIN_XMLNS}; +use crate::domain::EPP_DOMAIN_XMLNS; use crate::request::CommandWithExtension; use crate::response::EppCommandResponse; use chrono::{DateTime, SecondsFormat, Utc}; @@ -20,7 +21,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::domain::rgp::report::{EppDomainRgpRestoreReport, EppDomainRgpRestoreReportResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// use chrono::{DateTime, NaiveDate}; /// use std::str::FromStr; /// diff --git a/epp-client/src/domain/rgp/request.rs b/epp-client/src/domain/rgp/request.rs index efafda4..c8a7760 100644 --- a/epp-client/src/domain/rgp/request.rs +++ b/epp-client/src/domain/rgp/request.rs @@ -3,8 +3,9 @@ use epp_client_macros::*; use crate::common::{ElementName, EmptyTag, EppObject, Extension}; +use crate::domain::rgp::EPP_DOMAIN_RGP_EXT_XMLNS; use crate::domain::update::{DomainChangeInfo, DomainUpdateRequest, DomainUpdateRequestData}; -use crate::epp::xml::{EPP_DOMAIN_RGP_EXT_XMLNS, EPP_DOMAIN_XMLNS}; +use crate::domain::EPP_DOMAIN_XMLNS; use crate::request::CommandWithExtension; use crate::response::CommandResponseWithExtension; use serde::{Deserialize, Serialize}; @@ -19,7 +20,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::domain::rgp::request::{EppDomainRgpRestoreRequest, EppDomainRgpRestoreRequestResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { diff --git a/epp-client/src/domain/transfer.rs b/epp-client/src/domain/transfer.rs index b7c6610..51e87f7 100644 --- a/epp-client/src/domain/transfer.rs +++ b/epp-client/src/domain/transfer.rs @@ -2,8 +2,8 @@ use epp_client_macros::*; +use super::EPP_DOMAIN_XMLNS; use crate::common::{DomainAuthInfo, ElementName, EppObject, Period, StringValue}; -use crate::epp::xml::EPP_DOMAIN_XMLNS; use crate::request::Command; use crate::response::{CommandResponse, EppCommandResponse}; use serde::{Deserialize, Serialize}; @@ -18,7 +18,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::domain::transfer::{EppDomainTransferRequest, EppDomainTransferRequestResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { @@ -68,7 +68,7 @@ pub type EppDomainTransferRequest = EppObject>; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::domain::transfer::{EppDomainTransferApprove, EppDomainTransferApproveResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { @@ -118,7 +118,7 @@ pub type EppDomainTransferApprove = EppObject>; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::domain::transfer::{EppDomainTransferReject, EppDomainTransferRejectResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { @@ -168,7 +168,7 @@ pub type EppDomainTransferReject = EppObject>; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::domain::transfer::{EppDomainTransferCancel, EppDomainTransferCancelResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { @@ -218,7 +218,7 @@ pub type EppDomainTransferCancel = EppObject>; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::domain::transfer::{EppDomainTransferQuery, EppDomainTransferQueryResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { diff --git a/epp-client/src/domain/update.rs b/epp-client/src/domain/update.rs index eb79af3..1ecc70c 100644 --- a/epp-client/src/domain/update.rs +++ b/epp-client/src/domain/update.rs @@ -6,7 +6,7 @@ use crate::common::{ DomainAuthInfo, DomainContact, DomainStatus, ElementName, EppObject, HostList, StringValue, }; -use crate::epp::xml::EPP_DOMAIN_XMLNS; +use super::EPP_DOMAIN_XMLNS; use crate::request::Command; use crate::response::EppCommandResponse; use serde::{Deserialize, Serialize}; @@ -23,7 +23,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::EppClient; /// use epp_client::common::{DomainStatus, DomainContact}; /// use epp_client::domain::update::{EppDomainUpdate, EppDomainUpdateResponse, DomainAddRemove}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { diff --git a/epp-client/src/epp.rs b/epp-client/src/epp.rs deleted file mode 100644 index eae5a0b..0000000 --- a/epp-client/src/epp.rs +++ /dev/null @@ -1,5 +0,0 @@ -//! Types for EPP requests and responses - -pub mod xml; - -pub use crate::connection::client::default_client_tr_id_fn as generate_client_tr_id; diff --git a/epp-client/src/epp/xml.rs b/epp-client/src/epp/xml.rs deleted file mode 100644 index a61d65b..0000000 --- a/epp-client/src/epp/xml.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! Types to use in serialization to and deserialization from EPP XML - -pub mod quick_xml; - -use std::{error::Error, fmt::Debug}; - -use crate::error; - -pub const EPP_XML_HEADER: &str = r#""#; - -pub const EPP_DOMAIN_XMLNS: &str = "urn:ietf:params:xml:ns:domain-1.0"; -pub const EPP_CONTACT_XMLNS: &str = "urn:ietf:params:xml:ns:contact-1.0"; -pub const EPP_HOST_XMLNS: &str = "urn:ietf:params:xml:ns:host-1.0"; - -pub const EPP_DOMAIN_RGP_EXT_XMLNS: &str = "urn:ietf:params:xml:ns:rgp-1.0"; - -pub const EPP_VERSION: &str = "1.0"; -pub const EPP_LANG: &str = "en"; - -/// Trait to be implemented by serializers. Currently the only included serializer is `quick-xml` -pub trait EppXml { - type Output: Debug; - - fn serialize(&self) -> Result>; - fn deserialize(epp_xml: &str) -> Result; -} diff --git a/epp-client/src/host.rs b/epp-client/src/host.rs index 035f812..75a6cab 100644 --- a/epp-client/src/host.rs +++ b/epp-client/src/host.rs @@ -3,3 +3,5 @@ pub mod create; pub mod delete; pub mod info; pub mod update; + +pub const EPP_HOST_XMLNS: &str = "urn:ietf:params:xml:ns:host-1.0"; diff --git a/epp-client/src/host/check.rs b/epp-client/src/host/check.rs index a1b4fa7..732bcce 100644 --- a/epp-client/src/host/check.rs +++ b/epp-client/src/host/check.rs @@ -3,7 +3,7 @@ use epp_client_macros::*; use crate::common::{ElementName, EppObject, StringValue}; -use crate::epp::xml::EPP_HOST_XMLNS; +use crate::host::EPP_HOST_XMLNS; use crate::request::Command; use crate::response::CommandResponse; use serde::{Deserialize, Serialize}; @@ -18,7 +18,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::host::check::{EppHostCheck, EppHostCheckResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { diff --git a/epp-client/src/host/create.rs b/epp-client/src/host/create.rs index 40c41bb..a282960 100644 --- a/epp-client/src/host/create.rs +++ b/epp-client/src/host/create.rs @@ -3,7 +3,7 @@ use epp_client_macros::*; use crate::common::{ElementName, EppObject, HostAddr, StringValue}; -use crate::epp::xml::EPP_HOST_XMLNS; +use crate::host::EPP_HOST_XMLNS; use crate::request::Command; use crate::response::CommandResponse; use serde::{Deserialize, Serialize}; @@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::EppClient; /// use epp_client::common::HostAddr; /// use epp_client::host::create::{EppHostCreate, EppHostCreateResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { diff --git a/epp-client/src/host/delete.rs b/epp-client/src/host/delete.rs index 0cfbb0e..bc20514 100644 --- a/epp-client/src/host/delete.rs +++ b/epp-client/src/host/delete.rs @@ -3,7 +3,7 @@ use epp_client_macros::*; use crate::common::{ElementName, EppObject, StringValue}; -use crate::epp::xml::EPP_HOST_XMLNS; +use crate::host::EPP_HOST_XMLNS; use crate::request::Command; use crate::response::EppCommandResponse; use serde::{Deserialize, Serialize}; @@ -18,7 +18,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::host::delete::{EppHostDelete, EppHostDeleteResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { diff --git a/epp-client/src/host/info.rs b/epp-client/src/host/info.rs index 90da0af..dc34f1b 100644 --- a/epp-client/src/host/info.rs +++ b/epp-client/src/host/info.rs @@ -3,7 +3,7 @@ use epp_client_macros::*; use crate::common::{ElementName, EppObject, HostAddr, HostStatus, StringValue}; -use crate::epp::xml::EPP_HOST_XMLNS; +use crate::host::EPP_HOST_XMLNS; use crate::request::Command; use crate::response::CommandResponse; use serde::{Deserialize, Serialize}; @@ -18,7 +18,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::host::info::{EppHostInfo, EppHostInfoResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { diff --git a/epp-client/src/host/update.rs b/epp-client/src/host/update.rs index 18b46a6..9e1d042 100644 --- a/epp-client/src/host/update.rs +++ b/epp-client/src/host/update.rs @@ -3,7 +3,7 @@ use epp_client_macros::*; use crate::common::{ElementName, EppObject, HostAddr, HostStatus, StringValue}; -use crate::epp::xml::EPP_HOST_XMLNS; +use crate::host::EPP_HOST_XMLNS; use crate::request::Command; use crate::response::EppCommandResponse; use serde::{Deserialize, Serialize}; @@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::EppClient; /// use epp_client::common::{HostAddr, HostStatus}; /// use epp_client::host::update::{EppHostUpdate, EppHostUpdateResponse, HostAddRemove, HostChangeInfo}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { diff --git a/epp-client/src/lib.rs b/epp-client/src/lib.rs index af4f1ff..a37fb55 100644 --- a/epp-client/src/lib.rs +++ b/epp-client/src/lib.rs @@ -44,7 +44,7 @@ //! use epp_client::config::{EppClientConfig, EppClientConnection}; //! use epp_client::EppClient; //! use epp_client::domain::check::{EppDomainCheck, EppDomainCheckResponse}; -//! use epp_client::epp::generate_client_tr_id; +//! use epp_client::generate_client_tr_id; //! //! #[tokio::main] //! async fn main() { @@ -105,13 +105,15 @@ pub mod config; pub mod connection; pub mod contact; pub mod domain; -pub mod epp; pub mod error; pub mod host; pub mod message; pub mod request; pub mod response; +pub mod xml; pub use connection::client::EppClient; +pub use crate::connection::client::default_client_tr_id_fn as generate_client_tr_id; + #[cfg(test)] pub mod tests; diff --git a/epp-client/src/message/ack.rs b/epp-client/src/message/ack.rs index 11835f9..a17640c 100644 --- a/epp-client/src/message/ack.rs +++ b/epp-client/src/message/ack.rs @@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::message::ack::{EppMessageAck, EppMessageAckResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { diff --git a/epp-client/src/message/poll.rs b/epp-client/src/message/poll.rs index 4f91f7d..7736052 100644 --- a/epp-client/src/message/poll.rs +++ b/epp-client/src/message/poll.rs @@ -17,7 +17,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::message::poll::{EppMessagePoll, EppMessagePollResponse}; -/// use epp_client::epp::generate_client_tr_id; +/// use epp_client::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { diff --git a/epp-client/src/request.rs b/epp-client/src/request.rs index a6397c9..9973ff2 100644 --- a/epp-client/src/request.rs +++ b/epp-client/src/request.rs @@ -9,10 +9,15 @@ use crate::{ ElementName, EmptyTag, EppObject, Extension, Options, ServiceExtension, Services, StringValue, }, - epp::xml::{EPP_CONTACT_XMLNS, EPP_DOMAIN_XMLNS, EPP_HOST_XMLNS, EPP_LANG, EPP_VERSION}, + contact::EPP_CONTACT_XMLNS, + domain::EPP_DOMAIN_XMLNS, + host::EPP_HOST_XMLNS, }; use epp_client_macros::*; +pub const EPP_VERSION: &str = "1.0"; +pub const EPP_LANG: &str = "en"; + /// Type corresponding to the <command> tag in an EPP XML request /// without an <extension> tag pub type Command = CommandWithExtension; diff --git a/epp-client/src/tests/de.rs b/epp-client/src/tests/de.rs index 0c31606..1357c07 100644 --- a/epp-client/src/tests/de.rs +++ b/epp-client/src/tests/de.rs @@ -20,7 +20,6 @@ mod response { use crate::domain::transfer::EppDomainTransferRejectResponse; use crate::domain::transfer::EppDomainTransferRequestResponse; use crate::domain::update::EppDomainUpdateResponse; - use crate::epp::xml::EppXml; use crate::host::check::EppHostCheckResponse; use crate::host::create::EppHostCreateResponse; use crate::host::delete::EppHostDeleteResponse; @@ -33,6 +32,7 @@ mod response { use crate::response::{ EppCommandResponseError, EppGreeting, EppLoginResponse, EppLogoutResponse, }; + use crate::xml::EppXml; const SVTRID: &str = "RO-6879-1627224678242975"; const SUCCESS_MSG: &str = "Command completed successfully"; diff --git a/epp-client/src/tests/se.rs b/epp-client/src/tests/se.rs index 01592c9..4103a82 100644 --- a/epp-client/src/tests/se.rs +++ b/epp-client/src/tests/se.rs @@ -27,7 +27,6 @@ mod request { use crate::domain::update::DomainAddRemove; use crate::domain::update::DomainChangeInfo; use crate::domain::update::EppDomainUpdate; - use crate::epp::xml::EppXml; use crate::host::check::EppHostCheck; use crate::host::create::EppHostCreate; use crate::host::delete::EppHostDelete; @@ -38,6 +37,7 @@ mod request { use crate::message::ack::EppMessageAck; use crate::message::poll::EppMessagePoll; use crate::request::{EppHello, EppLogin, EppLogout}; + use crate::xml::EppXml; use chrono::{DateTime, NaiveDate}; use std::str::FromStr; diff --git a/epp-client/src/epp/xml/quick_xml.rs b/epp-client/src/xml.rs similarity index 70% rename from epp-client/src/epp/xml/quick_xml.rs rename to epp-client/src/xml.rs index 935d07c..2b83c95 100644 --- a/epp-client/src/epp/xml/quick_xml.rs +++ b/epp-client/src/xml.rs @@ -1,4 +1,4 @@ -//! XML serialization using the `quick-xml` library +//! Types to use in serialization to and deserialization from EPP XML use quick_xml::de::from_str; use quick_xml::se; @@ -6,9 +6,10 @@ use serde::{de::DeserializeOwned, Serialize}; use std::{error::Error, fmt::Debug}; use crate::common::{ElementName, EppObject}; -use crate::epp::xml::{EppXml, EPP_XML_HEADER}; use crate::error; +pub const EPP_XML_HEADER: &str = r#""#; + impl EppXml for EppObject { type Output = EppObject; @@ -34,3 +35,11 @@ impl EppXml for EppObject Ok(object) } } + +/// Trait to be implemented by serializers. Currently the only included serializer is `quick-xml` +pub trait EppXml { + type Output: Debug; + + fn serialize(&self) -> Result>; + fn deserialize(epp_xml: &str) -> Result; +}