fixed element name macro for generic attrs

This commit is contained in:
Ritesh Chitlangi 2021-07-22 18:44:38 +08:00
parent fd72c80023
commit d991fdec26
3 changed files with 15 additions and 11 deletions

View File

@ -1,4 +1,6 @@
use epp_client::{epp::request::generate_client_tr_id, connection::EppClient, connection, epp::xml::EppXml, epp::response::EppGreeting};
use epp_client::{epp::request::generate_client_tr_id, connection::EppClient, connection, epp::xml::EppXml};
use epp_client::epp::request::EppHello;
use epp_client::epp::response::EppGreeting;
use epp_client::epp::request::domain::check::EppDomainCheck;
use epp_client::epp::response::domain::check::EppDomainCheckResponse;
use epp_client::epp::request::contact::check::EppContactCheck;
@ -37,6 +39,12 @@ async fn create_contact() {
//client.transact::<EppContactCheck, EppContactCheckResponse>(&contact_check).await.unwrap();
}
async fn hello(client: &mut EppClient) {
let hello = EppHello::new();
client.transact::<_, EppGreeting>(&hello).await.unwrap();
}
#[tokio::main]
async fn main() {
let mut client = match connection::connect("hexonet").await {
@ -49,9 +57,11 @@ async fn main() {
Err(e) => panic!("Error: {}", e)
};
hello(&mut client).await;
// check_domains(&mut client).await;
check_contacts(&mut client).await;
// check_contacts(&mut client).await;
// create_contact().await;
}

View File

@ -1,20 +1,16 @@
use crate::epp::object::{ElementName, StringValue};
use epp_client_macros::*;
use serde::ser::{SerializeStruct, Serializer};
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Debug, PartialEq)]
#[derive(Deserialize, Debug, PartialEq, ElementName)]
#[element_name(name = "command")]
pub struct Command<T: ElementName> {
pub command: T,
#[serde(rename = "clTRID")]
pub client_tr_id: StringValue,
}
impl<T: ElementName> ElementName for Command<T> {
fn element_name(&self) -> &'static str {
"command"
}
}
impl<T: ElementName + Serialize> Serialize for Command<T> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where

View File

@ -22,7 +22,6 @@ pub fn generate_client_tr_id(username: &str) -> Result<String, Box<dyn Error>> {
}
#[derive(Serialize, Deserialize, Debug, PartialEq, ElementName)]
#[serde(rename = "hello")]
#[element_name(name = "hello")]
pub struct Hello;
@ -33,7 +32,6 @@ impl EppHello {
}
#[derive(Serialize, Deserialize, Debug, PartialEq, ElementName)]
#[serde(rename = "login")]
#[element_name(name = "login")]
pub struct Login {
#[serde(rename(serialize = "clID", deserialize = "clID"))]