Share the Available type across domain and host

This commit is contained in:
Dirkjan Ochtman 2022-01-27 12:08:11 +01:00 committed by masalachai
parent a6dfe70361
commit 999149ba31
3 changed files with 15 additions and 26 deletions

View File

@ -39,6 +39,17 @@ impl Extension for NoExtension {
type Response = NoExtension;
}
/// Type that represents the <name> tag for host check response
#[derive(Deserialize, Debug)]
pub struct Available {
/// The resource name
#[serde(rename = "$value")]
pub name: StringValue<'static>,
/// The resource (un)availability
#[serde(rename = "avail")]
pub available: bool,
}
/// The <option> type in EPP XML login requests
#[derive(Serialize, Deserialize, Debug, PartialEq)]
#[serde(rename = "options")]

View File

@ -1,7 +1,7 @@
//! Types for EPP domain check request
use super::XMLNS;
use crate::common::{NoExtension, StringValue};
use crate::common::{NoExtension, StringValue, Available};
use crate::request::{Command, Transaction};
use serde::{Deserialize, Serialize};
@ -46,23 +46,12 @@ pub struct DomainCheck<'a> {
// Response
/// Type that represents the &lt;name&gt; tag for domain check response
#[derive(Deserialize, Debug)]
pub struct DomainAvailable {
/// The domain name
#[serde(rename = "$value")]
pub name: StringValue<'static>,
/// The domain (un)availability
#[serde(rename = "avail")]
pub available: bool,
}
/// Type that represents the &lt;cd&gt; tag for domain check response
#[derive(Deserialize, Debug)]
pub struct DomainCheckResponseDataItem {
/// Data under the &lt;name&gt; tag
#[serde(rename = "name")]
pub domain: DomainAvailable,
pub domain: Available,
/// The reason for (un)availability
pub reason: Option<StringValue<'static>>,
}

View File

@ -3,7 +3,7 @@
use std::fmt::Debug;
use super::XMLNS;
use crate::common::{NoExtension, StringValue};
use crate::common::{NoExtension, StringValue, Available};
use crate::request::{Command, Transaction};
use serde::{Deserialize, Serialize};
@ -50,23 +50,12 @@ pub struct HostCheck<'a> {
// Response
/// Type that represents the &lt;name&gt; tag for host check response
#[derive(Deserialize, Debug)]
pub struct HostAvailable {
/// The host name
#[serde(rename = "$value")]
pub name: StringValue<'static>,
/// The host (un)availability
#[serde(rename = "avail")]
pub available: bool,
}
/// Type that represents the &lt;cd&gt; tag for host check response
#[derive(Deserialize, Debug)]
pub struct HostCheckDataItem {
/// Data under the &lt;name&gt; tag
#[serde(rename = "name")]
pub host: HostAvailable,
pub host: Available,
/// The reason for (un)availability
pub reason: Option<StringValue<'static>>,
}