Store a Cow<'a, str> in StringValue
And parametrize all serialize-only types with a lifetime such that building requests no longer requires unnecessary allocations.
This commit is contained in:
parent
1efe19000e
commit
d4f4949cd8
|
@ -1,6 +1,6 @@
|
|||
//! Common data types included in EPP Requests and Responses
|
||||
|
||||
use std::fmt::Display;
|
||||
use std::{borrow::Cow, fmt::Display};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
@ -11,23 +11,23 @@ pub(crate) const EPP_XMLNS: &str = "urn:ietf:params:xml:ns:epp-1.0";
|
|||
/// Wraps String for easier serialization to and from values that are inner text
|
||||
/// for tags rather than attributes
|
||||
#[derive(Default, Serialize, Deserialize, Debug, PartialEq, Clone)]
|
||||
pub struct StringValue(String);
|
||||
pub struct StringValue<'a>(Cow<'a, str>);
|
||||
|
||||
impl Display for StringValue {
|
||||
impl Display for StringValue<'_> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&str> for StringValue {
|
||||
fn from(s: &str) -> Self {
|
||||
Self(s.to_owned())
|
||||
impl<'a> From<&'a str> for StringValue<'a> {
|
||||
fn from(s: &'a str) -> Self {
|
||||
Self(s.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for StringValue {
|
||||
impl From<String> for StringValue<'static> {
|
||||
fn from(s: String) -> Self {
|
||||
Self(s)
|
||||
Self(s.into())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,17 +42,17 @@ impl Extension for NoExtension {
|
|||
/// The <option> type in EPP XML login requests
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
#[serde(rename = "options")]
|
||||
pub struct Options {
|
||||
pub struct Options<'a> {
|
||||
/// The EPP version being used
|
||||
pub version: StringValue,
|
||||
pub version: StringValue<'a>,
|
||||
/// The language that will be used during EPP transactions
|
||||
pub lang: StringValue,
|
||||
pub lang: StringValue<'a>,
|
||||
}
|
||||
|
||||
impl Options {
|
||||
impl<'a> Options<'a> {
|
||||
/// Creates an Options object with version and lang data
|
||||
pub fn build(version: &str, lang: &str) -> Options {
|
||||
Options {
|
||||
pub fn build(version: &'a str, lang: &'a str) -> Self {
|
||||
Self {
|
||||
version: version.into(),
|
||||
lang: lang.into(),
|
||||
}
|
||||
|
@ -62,21 +62,21 @@ impl Options {
|
|||
/// The <svcExtension> type in EPP XML
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
#[serde(rename = "svcExtension")]
|
||||
pub struct ServiceExtension {
|
||||
pub struct ServiceExtension<'a> {
|
||||
/// The service extension URIs being represented by <extURI> in EPP XML
|
||||
#[serde(rename = "extURI")]
|
||||
pub ext_uris: Option<Vec<StringValue>>,
|
||||
pub ext_uris: Option<Vec<StringValue<'a>>>,
|
||||
}
|
||||
|
||||
/// The <svcs> type in EPP XML
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
pub struct Services {
|
||||
pub struct Services<'a> {
|
||||
/// The service URIs being used by this EPP session represented by <objURI> in EPP XML
|
||||
#[serde(rename = "objURI")]
|
||||
pub obj_uris: Vec<StringValue>,
|
||||
pub obj_uris: Vec<StringValue<'a>>,
|
||||
/// The <svcExtention> being used in this EPP session
|
||||
#[serde(rename = "svcExtension")]
|
||||
pub svc_ext: Option<ServiceExtension>,
|
||||
pub svc_ext: Option<ServiceExtension<'a>>,
|
||||
}
|
||||
|
||||
/// The <hostAddr> types domain or host transactions
|
||||
|
|
|
@ -33,16 +33,16 @@ impl std::ops::Deref for Country {
|
|||
|
||||
/// The <authInfo> tag for domain and contact transactions
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct ContactAuthInfo {
|
||||
pub struct ContactAuthInfo<'a> {
|
||||
/// The <pw> tag under <authInfo>
|
||||
#[serde(rename = "contact:pw", alias = "pw")]
|
||||
pub password: StringValue,
|
||||
pub password: StringValue<'a>,
|
||||
}
|
||||
|
||||
impl ContactAuthInfo {
|
||||
impl<'a> ContactAuthInfo<'a> {
|
||||
/// Creates a ContactAuthInfo instance with the given password
|
||||
pub fn new(password: &str) -> ContactAuthInfo {
|
||||
ContactAuthInfo {
|
||||
pub fn new(password: &'a str) -> Self {
|
||||
Self {
|
||||
password: password.into(),
|
||||
}
|
||||
}
|
||||
|
@ -76,36 +76,36 @@ impl Phone {
|
|||
|
||||
/// The <addr> type on contact transactions
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct Address {
|
||||
pub struct Address<'a> {
|
||||
/// The <street> tags under <addr>
|
||||
#[serde(rename = "contact:street", alias = "street")]
|
||||
pub street: Vec<StringValue>,
|
||||
pub street: Vec<StringValue<'a>>,
|
||||
/// The <city> tag under <addr>
|
||||
#[serde(rename = "contact:city", alias = "city")]
|
||||
pub city: StringValue,
|
||||
pub city: StringValue<'a>,
|
||||
/// The <sp> tag under <addr>
|
||||
#[serde(rename = "contact:sp", alias = "sp")]
|
||||
pub province: StringValue,
|
||||
pub province: StringValue<'a>,
|
||||
/// The <pc> tag under <addr>
|
||||
#[serde(rename = "contact:pc", alias = "pc")]
|
||||
pub postal_code: StringValue,
|
||||
pub postal_code: StringValue<'a>,
|
||||
/// The <cc> tag under <addr>
|
||||
#[serde(rename = "contact:cc", alias = "cc")]
|
||||
pub country: Country,
|
||||
}
|
||||
|
||||
impl Address {
|
||||
impl<'a> Address<'a> {
|
||||
/// Creates a new Address instance
|
||||
pub fn new(
|
||||
street: &[&str],
|
||||
city: &str,
|
||||
province: &str,
|
||||
postal_code: &str,
|
||||
street: &[&'a str],
|
||||
city: &'a str,
|
||||
province: &'a str,
|
||||
postal_code: &'a str,
|
||||
country: Country,
|
||||
) -> Address {
|
||||
) -> Self {
|
||||
let street = street.iter().map(|&s| s.into()).collect();
|
||||
|
||||
Address {
|
||||
Self {
|
||||
street,
|
||||
city: city.into(),
|
||||
province: province.into(),
|
||||
|
@ -117,25 +117,25 @@ impl Address {
|
|||
|
||||
/// The <postalInfo> type on contact transactions
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct PostalInfo {
|
||||
pub struct PostalInfo<'a> {
|
||||
/// The 'type' attr on <postalInfo>
|
||||
#[serde(rename = "type")]
|
||||
pub info_type: String,
|
||||
/// The <name> tag under <postalInfo>
|
||||
#[serde(rename = "contact:name", alias = "name")]
|
||||
pub name: StringValue,
|
||||
pub name: StringValue<'a>,
|
||||
/// The <org> tag under <postalInfo>
|
||||
#[serde(rename = "contact:org", alias = "org")]
|
||||
pub organization: StringValue,
|
||||
pub organization: StringValue<'a>,
|
||||
/// The <addr> tag under <postalInfo>
|
||||
#[serde(rename = "contact:addr", alias = "addr")]
|
||||
pub address: Address,
|
||||
pub address: Address<'a>,
|
||||
}
|
||||
|
||||
impl PostalInfo {
|
||||
impl<'a> PostalInfo<'a> {
|
||||
/// Creates a new PostalInfo instance
|
||||
pub fn new(info_type: &str, name: &str, organization: &str, address: Address) -> PostalInfo {
|
||||
PostalInfo {
|
||||
pub fn new(info_type: &str, name: &'a str, organization: &'a str, address: Address<'a>) -> Self {
|
||||
Self {
|
||||
info_type: info_type.to_string(),
|
||||
name: name.into(),
|
||||
organization: organization.into(),
|
||||
|
|
|
@ -6,35 +6,32 @@ use crate::common::{NoExtension, StringValue};
|
|||
use crate::request::{Command, Transaction};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
impl Transaction<NoExtension> for ContactCheck {}
|
||||
impl<'a> Transaction<NoExtension> for ContactCheck<'a> {}
|
||||
|
||||
// Request
|
||||
|
||||
/// Type that represents the <check> command for contact transactions
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct ContactList {
|
||||
pub struct ContactList<'a> {
|
||||
/// The XML namespace for the contact <check>
|
||||
#[serde(rename = "xmlns:contact")]
|
||||
xmlns: &'static str,
|
||||
xmlns: &'a str,
|
||||
/// The list of contact ids to check for availability
|
||||
#[serde(rename = "contact:id")]
|
||||
pub contact_ids: Vec<StringValue>,
|
||||
pub contact_ids: Vec<StringValue<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
/// The <command> type for contact check command
|
||||
pub struct ContactCheck {
|
||||
pub struct ContactCheck<'a> {
|
||||
/// The <check> tag for the contact check command
|
||||
#[serde(rename = "contact:check")]
|
||||
list: ContactList,
|
||||
list: ContactList<'a>,
|
||||
}
|
||||
|
||||
impl ContactCheck {
|
||||
pub fn new(contact_ids: &[&str]) -> Self {
|
||||
let contact_ids = contact_ids
|
||||
.iter()
|
||||
.map(|&d| d.into())
|
||||
.collect::<Vec<StringValue>>();
|
||||
impl<'a> ContactCheck<'a> {
|
||||
pub fn new(contact_ids: &[&'a str]) -> Self {
|
||||
let contact_ids = contact_ids.iter().map(|&d| d.into()).collect();
|
||||
|
||||
Self {
|
||||
list: ContactList {
|
||||
|
@ -45,7 +42,7 @@ impl ContactCheck {
|
|||
}
|
||||
}
|
||||
|
||||
impl Command for ContactCheck {
|
||||
impl<'a> Command for ContactCheck<'a> {
|
||||
type Response = ContactCheckResponse;
|
||||
const COMMAND: &'static str = "check";
|
||||
}
|
||||
|
@ -57,7 +54,7 @@ impl Command for ContactCheck {
|
|||
pub struct ContactAvailable {
|
||||
/// The text of the <id> tag
|
||||
#[serde(rename = "$value")]
|
||||
pub id: StringValue,
|
||||
pub id: StringValue<'static>,
|
||||
/// The avail attr on the <id> tag
|
||||
#[serde(rename = "avail")]
|
||||
pub available: u16,
|
||||
|
@ -70,7 +67,7 @@ pub struct ContactCheckResponseDataItem {
|
|||
#[serde(rename = "id")]
|
||||
pub contact: ContactAvailable,
|
||||
/// The reason for (un)availability
|
||||
pub reason: Option<StringValue>,
|
||||
pub reason: Option<StringValue<'static>>,
|
||||
}
|
||||
|
||||
/// Type that represents the <chkData> tag for contact check response
|
||||
|
|
|
@ -5,9 +5,9 @@ use crate::common::{NoExtension, StringValue};
|
|||
use crate::request::{Command, Transaction};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
impl Transaction<NoExtension> for ContactCreate {}
|
||||
impl<'a> Transaction<NoExtension> for ContactCreate<'a> {}
|
||||
|
||||
impl Command for ContactCreate {
|
||||
impl<'a> Command for ContactCreate<'a> {
|
||||
type Response = ContactCreateResponse;
|
||||
const COMMAND: &'static str = "create";
|
||||
}
|
||||
|
@ -16,16 +16,16 @@ impl Command for ContactCreate {
|
|||
|
||||
/// Type for elements under the contact <create> tag
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct Contact {
|
||||
pub struct Contact<'a> {
|
||||
/// XML namespace for contact commands
|
||||
#[serde(rename = "xmlns:contact")]
|
||||
xmlns: &'static str,
|
||||
xmlns: &'a str,
|
||||
/// Contact <id> tag
|
||||
#[serde(rename = "contact:id")]
|
||||
id: StringValue,
|
||||
id: StringValue<'a>,
|
||||
/// Contact <postalInfo> tag
|
||||
#[serde(rename = "contact:postalInfo")]
|
||||
postal_info: PostalInfo,
|
||||
postal_info: PostalInfo<'a>,
|
||||
/// Contact <voice> tag
|
||||
#[serde(rename = "contact:voice")]
|
||||
voice: Phone,
|
||||
|
@ -34,27 +34,27 @@ pub struct Contact {
|
|||
fax: Option<Phone>,
|
||||
/// Contact <email> tag
|
||||
#[serde(rename = "contact:email")]
|
||||
email: StringValue,
|
||||
email: StringValue<'a>,
|
||||
/// Contact <authInfo> tag
|
||||
#[serde(rename = "contact:authInfo")]
|
||||
auth_info: ContactAuthInfo,
|
||||
auth_info: ContactAuthInfo<'a>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
/// Type for EPP XML <create> command for contacts
|
||||
pub struct ContactCreate {
|
||||
pub struct ContactCreate<'a> {
|
||||
/// Data for <create> command for contact
|
||||
#[serde(rename = "contact:create")]
|
||||
pub contact: Contact,
|
||||
pub contact: Contact<'a>,
|
||||
}
|
||||
|
||||
impl ContactCreate {
|
||||
impl<'a> ContactCreate<'a> {
|
||||
pub fn new(
|
||||
id: &str,
|
||||
email: &str,
|
||||
postal_info: PostalInfo,
|
||||
id: &'a str,
|
||||
email: &'a str,
|
||||
postal_info: PostalInfo<'a>,
|
||||
voice: Phone,
|
||||
auth_password: &str,
|
||||
auth_password: &'a str,
|
||||
) -> Self {
|
||||
Self {
|
||||
contact: Contact {
|
||||
|
@ -81,10 +81,10 @@ impl ContactCreate {
|
|||
#[derive(Deserialize, Debug)]
|
||||
pub struct ContactCreateData {
|
||||
/// The contact id
|
||||
pub id: StringValue,
|
||||
pub id: StringValue<'static>,
|
||||
#[serde(rename = "crDate")]
|
||||
/// The contact creation date
|
||||
pub created_at: StringValue,
|
||||
pub created_at: StringValue<'static>,
|
||||
}
|
||||
|
||||
/// Type that represents the <resData> tag for contact create response
|
||||
|
|
|
@ -5,34 +5,34 @@ use crate::common::{NoExtension, StringValue};
|
|||
use crate::request::{Command, Transaction};
|
||||
use serde::Serialize;
|
||||
|
||||
impl Transaction<NoExtension> for ContactDelete {}
|
||||
impl<'a> Transaction<NoExtension> for ContactDelete<'a> {}
|
||||
|
||||
impl Command for ContactDelete {
|
||||
impl<'a> Command for ContactDelete<'a> {
|
||||
type Response = ();
|
||||
const COMMAND: &'static str = "delete";
|
||||
}
|
||||
|
||||
/// Type containing the data for the <delete> tag for contacts
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct ContactDeleteRequestData {
|
||||
pub struct ContactDeleteRequestData<'a> {
|
||||
/// XML namespace for the <delete> command for contacts
|
||||
#[serde(rename = "xmlns:contact")]
|
||||
xmlns: &'static str,
|
||||
xmlns: &'a str,
|
||||
/// The id of the contact to be deleted
|
||||
#[serde(rename = "contact:id")]
|
||||
id: StringValue,
|
||||
id: StringValue<'a>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
/// The <delete> type for the contact delete EPP command
|
||||
pub struct ContactDelete {
|
||||
pub struct ContactDelete<'a> {
|
||||
#[serde(rename = "contact:delete")]
|
||||
/// The data for the <delete> tag for a contact delete command
|
||||
contact: ContactDeleteRequestData,
|
||||
contact: ContactDeleteRequestData<'a>,
|
||||
}
|
||||
|
||||
impl ContactDelete {
|
||||
pub fn new(id: &str) -> ContactDelete {
|
||||
impl<'a> ContactDelete<'a> {
|
||||
pub fn new(id: &'a str) -> Self {
|
||||
Self {
|
||||
contact: ContactDeleteRequestData {
|
||||
xmlns: XMLNS,
|
||||
|
|
|
@ -5,9 +5,9 @@ use crate::common::{NoExtension, ObjectStatus, StringValue};
|
|||
use crate::request::{Command, Transaction};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
impl Transaction<NoExtension> for ContactInfo {}
|
||||
impl<'a> Transaction<NoExtension> for ContactInfo<'a> {}
|
||||
|
||||
impl Command for ContactInfo {
|
||||
impl<'a> Command for ContactInfo<'a> {
|
||||
type Response = ContactInfoResponse;
|
||||
const COMMAND: &'static str = "info";
|
||||
}
|
||||
|
@ -16,28 +16,28 @@ impl Command for ContactInfo {
|
|||
|
||||
/// Type for elements under the contact <info> tag
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct ContactInfoRequestData {
|
||||
pub struct ContactInfoRequestData<'a> {
|
||||
/// XML namespace for contact commands
|
||||
#[serde(rename = "xmlns:contact")]
|
||||
xmlns: &'static str,
|
||||
xmlns: &'a str,
|
||||
/// The contact id for the info command
|
||||
#[serde(rename = "contact:id")]
|
||||
id: StringValue,
|
||||
id: StringValue<'a>,
|
||||
/// The <authInfo> data
|
||||
#[serde(rename = "contact:authInfo")]
|
||||
auth_info: ContactAuthInfo,
|
||||
auth_info: ContactAuthInfo<'a>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
/// Type for EPP XML <info> command for contacts
|
||||
pub struct ContactInfo {
|
||||
pub struct ContactInfo<'a> {
|
||||
/// Data for <info> command for contact
|
||||
#[serde(rename = "contact:info")]
|
||||
info: ContactInfoRequestData,
|
||||
info: ContactInfoRequestData<'a>,
|
||||
}
|
||||
|
||||
impl ContactInfo {
|
||||
pub fn new(id: &str, auth_password: &str) -> ContactInfo {
|
||||
impl<'a> ContactInfo<'a> {
|
||||
pub fn new(id: &'a str, auth_password: &'a str) -> ContactInfo<'a> {
|
||||
Self {
|
||||
info: ContactInfoRequestData {
|
||||
xmlns: XMLNS,
|
||||
|
@ -52,44 +52,44 @@ impl ContactInfo {
|
|||
|
||||
/// Type that represents the <infData> tag for contact check response
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct ContactInfoData {
|
||||
pub struct ContactInfoData<'a> {
|
||||
/// The contact id
|
||||
pub id: StringValue,
|
||||
pub id: StringValue<'a>,
|
||||
/// The contact ROID
|
||||
pub roid: StringValue,
|
||||
pub roid: StringValue<'a>,
|
||||
/// The list of contact statuses
|
||||
#[serde(rename = "status")]
|
||||
pub statuses: Vec<ObjectStatus>,
|
||||
/// The postal info for the contact
|
||||
#[serde(rename = "postalInfo")]
|
||||
pub postal_info: PostalInfo,
|
||||
pub postal_info: PostalInfo<'a>,
|
||||
/// The voice data for the contact
|
||||
pub voice: Phone,
|
||||
/// The fax data for the contact
|
||||
pub fax: Option<Phone>,
|
||||
/// The email for the contact
|
||||
pub email: StringValue,
|
||||
pub email: StringValue<'a>,
|
||||
/// The epp user to whom the contact belongs
|
||||
#[serde(rename = "clID")]
|
||||
pub client_id: StringValue,
|
||||
pub client_id: StringValue<'a>,
|
||||
/// The epp user who created the contact
|
||||
#[serde(rename = "crID")]
|
||||
pub creator_id: StringValue,
|
||||
pub creator_id: StringValue<'a>,
|
||||
/// The creation date
|
||||
#[serde(rename = "crDate")]
|
||||
pub created_at: StringValue,
|
||||
pub created_at: StringValue<'a>,
|
||||
/// The epp user who last updated the contact
|
||||
#[serde(rename = "upID")]
|
||||
pub updater_id: Option<StringValue>,
|
||||
pub updater_id: Option<StringValue<'a>>,
|
||||
/// The last update date
|
||||
#[serde(rename = "upDate")]
|
||||
pub updated_at: Option<StringValue>,
|
||||
pub updated_at: Option<StringValue<'a>>,
|
||||
/// The contact transfer date
|
||||
#[serde(rename = "trDate")]
|
||||
pub transferred_at: Option<StringValue>,
|
||||
pub transferred_at: Option<StringValue<'a>>,
|
||||
/// The contact auth info
|
||||
#[serde(rename = "authInfo")]
|
||||
pub auth_info: Option<ContactAuthInfo>,
|
||||
pub auth_info: Option<ContactAuthInfo<'a>>,
|
||||
}
|
||||
|
||||
/// Type that represents the <resData> tag for contact info response
|
||||
|
@ -97,7 +97,7 @@ pub struct ContactInfoData {
|
|||
pub struct ContactInfoResponse {
|
||||
/// Data under the <infData> tag
|
||||
#[serde(rename = "infData")]
|
||||
pub info_data: ContactInfoData,
|
||||
pub info_data: ContactInfoData<'static>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -5,15 +5,15 @@ use crate::common::{NoExtension, ObjectStatus, StringValue};
|
|||
use crate::request::{Command, Transaction};
|
||||
use serde::Serialize;
|
||||
|
||||
impl Transaction<NoExtension> for ContactUpdate {}
|
||||
impl<'a> Transaction<NoExtension> for ContactUpdate<'a> {}
|
||||
|
||||
impl Command for ContactUpdate {
|
||||
impl<'a> Command for ContactUpdate<'a> {
|
||||
type Response = ();
|
||||
const COMMAND: &'static str = "update";
|
||||
}
|
||||
|
||||
impl ContactUpdate {
|
||||
pub fn new(id: &str) -> ContactUpdate {
|
||||
impl<'a> ContactUpdate<'a> {
|
||||
pub fn new(id: &'a str) -> ContactUpdate {
|
||||
Self {
|
||||
contact: ContactUpdateRequestData {
|
||||
xmlns: XMLNS,
|
||||
|
@ -28,10 +28,10 @@ impl ContactUpdate {
|
|||
/// Sets the data for the <chg> tag for the contact update request
|
||||
pub fn set_info(
|
||||
&mut self,
|
||||
email: &str,
|
||||
postal_info: PostalInfo,
|
||||
email: &'a str,
|
||||
postal_info: PostalInfo<'a>,
|
||||
voice: Phone,
|
||||
auth_password: &str,
|
||||
auth_password: &'a str,
|
||||
) {
|
||||
self.contact.change_info = Some(ContactChangeInfo {
|
||||
email: Some(email.into()),
|
||||
|
@ -62,17 +62,17 @@ impl ContactUpdate {
|
|||
|
||||
/// Type for elements under the <chg> tag for contact update request
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct ContactChangeInfo {
|
||||
pub struct ContactChangeInfo<'a> {
|
||||
#[serde(rename = "contact:postalInfo")]
|
||||
postal_info: Option<PostalInfo>,
|
||||
postal_info: Option<PostalInfo<'a>>,
|
||||
#[serde(rename = "contact:voice")]
|
||||
voice: Option<Phone>,
|
||||
#[serde(rename = "contact:fax")]
|
||||
fax: Option<Phone>,
|
||||
#[serde(rename = "contact:email")]
|
||||
email: Option<StringValue>,
|
||||
email: Option<StringValue<'a>>,
|
||||
#[serde(rename = "contact:authInfo")]
|
||||
auth_info: Option<ContactAuthInfo>,
|
||||
auth_info: Option<ContactAuthInfo<'a>>,
|
||||
}
|
||||
|
||||
/// Type for list of elements of the <status> tag for contact update request
|
||||
|
@ -84,25 +84,25 @@ pub struct StatusList {
|
|||
|
||||
/// Type for elements under the contact <update> tag
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct ContactUpdateRequestData {
|
||||
pub struct ContactUpdateRequestData<'a> {
|
||||
#[serde(rename = "xmlns:contact")]
|
||||
xmlns: &'static str,
|
||||
xmlns: &'a str,
|
||||
#[serde(rename = "contact:id")]
|
||||
id: StringValue,
|
||||
id: StringValue<'a>,
|
||||
#[serde(rename = "contact:add")]
|
||||
add_statuses: Option<StatusList>,
|
||||
#[serde(rename = "contact:rem")]
|
||||
remove_statuses: Option<StatusList>,
|
||||
#[serde(rename = "contact:chg")]
|
||||
change_info: Option<ContactChangeInfo>,
|
||||
change_info: Option<ContactChangeInfo<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
/// Type for EPP XML <update> command for contacts
|
||||
pub struct ContactUpdate {
|
||||
pub struct ContactUpdate<'a> {
|
||||
/// The data under the <update> tag for the contact update
|
||||
#[serde(rename = "contact:update")]
|
||||
contact: ContactUpdateRequestData,
|
||||
contact: ContactUpdateRequestData<'a>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -14,10 +14,10 @@ pub const XMLNS: &str = "urn:ietf:params:xml:ns:domain-1.0";
|
|||
|
||||
/// The <hostAttr> type for domain transactions
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct HostAttr {
|
||||
pub struct HostAttr<'a> {
|
||||
/// The <hostName> tag
|
||||
#[serde(rename = "domain:hostName", alias = "hostName")]
|
||||
pub name: StringValue,
|
||||
pub name: StringValue<'a>,
|
||||
/// The <hostAddr> tags
|
||||
#[serde(rename = "domain:hostAddr", alias = "hostAddr")]
|
||||
pub addresses: Option<Vec<HostAddr>>,
|
||||
|
@ -25,27 +25,27 @@ pub struct HostAttr {
|
|||
|
||||
/// The list of <hostAttr> types for domain transactions. Typically under an <ns> tag
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct HostAttrList {
|
||||
pub struct HostAttrList<'a> {
|
||||
/// The list of <hostAttr> tags
|
||||
#[serde(rename = "domain:hostAttr", alias = "hostAttr")]
|
||||
pub hosts: Vec<HostAttr>,
|
||||
pub hosts: Vec<HostAttr<'a>>,
|
||||
}
|
||||
|
||||
/// The list of <hostObj> types for domain transactions. Typically under an <ns> tag
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct HostObjList {
|
||||
pub struct HostObjList<'a> {
|
||||
/// The list of <hostObj> tags
|
||||
#[serde(rename = "domain:hostObj", alias = "hostObj")]
|
||||
pub hosts: Vec<StringValue>,
|
||||
pub hosts: Vec<StringValue<'a>>,
|
||||
}
|
||||
|
||||
/// Enum that can accept one type which corresponds to either the <hostObj> or <hostAttr>
|
||||
/// list of tags
|
||||
#[derive(Serialize, Debug)]
|
||||
#[serde(untagged)]
|
||||
pub enum HostList {
|
||||
HostObjList(HostObjList),
|
||||
HostAttrList(HostAttrList),
|
||||
pub enum HostList<'a> {
|
||||
HostObjList(HostObjList<'a>),
|
||||
HostAttrList(HostAttrList<'a>),
|
||||
}
|
||||
|
||||
/// The <contact> type on domain creation and update requests
|
||||
|
@ -86,16 +86,16 @@ impl Period {
|
|||
|
||||
/// The <authInfo> tag for domain and contact transactions
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct DomainAuthInfo {
|
||||
pub struct DomainAuthInfo<'a> {
|
||||
/// The <pw> tag under <authInfo>
|
||||
#[serde(rename = "domain:pw", alias = "pw")]
|
||||
pub password: StringValue,
|
||||
pub password: StringValue<'a>,
|
||||
}
|
||||
|
||||
impl DomainAuthInfo {
|
||||
impl<'a> DomainAuthInfo<'a> {
|
||||
/// Creates a DomainAuthInfo instance with the given password
|
||||
pub fn new(password: &str) -> DomainAuthInfo {
|
||||
DomainAuthInfo {
|
||||
pub fn new(password: &'a str) -> Self {
|
||||
Self {
|
||||
password: password.into(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,22 +5,19 @@ use crate::common::{NoExtension, StringValue};
|
|||
use crate::request::{Command, Transaction};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
impl Transaction<NoExtension> for DomainCheck {}
|
||||
impl<'a> Transaction<NoExtension> for DomainCheck<'a> {}
|
||||
|
||||
impl Command for DomainCheck {
|
||||
impl<'a> Command for DomainCheck<'a> {
|
||||
type Response = DomainCheckResponse;
|
||||
const COMMAND: &'static str = "check";
|
||||
}
|
||||
|
||||
impl DomainCheck {
|
||||
pub fn new(domains: Vec<&str>) -> Self {
|
||||
impl<'a> DomainCheck<'a> {
|
||||
pub fn new(domains: Vec<&'a str>) -> Self {
|
||||
Self {
|
||||
list: DomainList {
|
||||
xmlns: XMLNS,
|
||||
domains: domains
|
||||
.into_iter()
|
||||
.map(|d| d.into())
|
||||
.collect::<Vec<StringValue>>(),
|
||||
domains: domains.into_iter().map(|d| d.into()).collect(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -30,21 +27,21 @@ impl DomainCheck {
|
|||
|
||||
/// Type for <name> elements under the domain <check> tag
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct DomainList {
|
||||
pub struct DomainList<'a> {
|
||||
#[serde(rename = "xmlns:domain")]
|
||||
/// XML namespace for domain commands
|
||||
pub xmlns: &'static str,
|
||||
pub xmlns: &'a str,
|
||||
#[serde(rename = "domain:name")]
|
||||
/// List of domains to be checked for availability
|
||||
pub domains: Vec<StringValue>,
|
||||
pub domains: Vec<StringValue<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
/// Type for EPP XML <check> command for domains
|
||||
pub struct DomainCheck {
|
||||
pub struct DomainCheck<'a> {
|
||||
/// The object holding the list of domains to be checked
|
||||
#[serde(rename = "domain:check")]
|
||||
list: DomainList,
|
||||
list: DomainList<'a>,
|
||||
}
|
||||
|
||||
// Response
|
||||
|
@ -54,7 +51,7 @@ pub struct DomainCheck {
|
|||
pub struct DomainAvailable {
|
||||
/// The domain name
|
||||
#[serde(rename = "$value")]
|
||||
pub name: StringValue,
|
||||
pub name: StringValue<'static>,
|
||||
/// The domain (un)availability
|
||||
#[serde(rename = "avail")]
|
||||
pub available: u16,
|
||||
|
@ -67,7 +64,7 @@ pub struct DomainCheckResponseDataItem {
|
|||
#[serde(rename = "name")]
|
||||
pub domain: DomainAvailable,
|
||||
/// The reason for (un)availability
|
||||
pub reason: Option<StringValue>,
|
||||
pub reason: Option<StringValue<'static>>,
|
||||
}
|
||||
|
||||
/// Type that represents the <chkData> tag for domain check response
|
||||
|
|
|
@ -6,9 +6,9 @@ use crate::request::{Command, Transaction};
|
|||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
impl Transaction<NoExtension> for DomainCreate {}
|
||||
impl<'a> Transaction<NoExtension> for DomainCreate<'a> {}
|
||||
|
||||
impl Command for DomainCreate {
|
||||
impl<'a> Command for DomainCreate<'a> {
|
||||
type Response = DomainCreateResponse;
|
||||
const COMMAND: &'static str = "create";
|
||||
}
|
||||
|
@ -17,48 +17,48 @@ impl Command for DomainCreate {
|
|||
|
||||
/// Type for elements under the domain <create> tag
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct DomainCreateRequestData {
|
||||
pub struct DomainCreateRequestData<'a> {
|
||||
/// XML namespace for domain commands
|
||||
#[serde(rename = "xmlns:domain")]
|
||||
pub xmlns: &'static str,
|
||||
pub xmlns: &'a str,
|
||||
/// The domain name
|
||||
#[serde(rename = "domain:name")]
|
||||
pub name: StringValue,
|
||||
pub name: StringValue<'a>,
|
||||
/// The period of registration
|
||||
#[serde(rename = "domain:period")]
|
||||
pub period: Period,
|
||||
/// The list of nameserver hosts
|
||||
/// either of type `HostObjList` or `HostAttrList`
|
||||
#[serde(rename = "domain:ns")]
|
||||
pub ns: Option<HostList>,
|
||||
pub ns: Option<HostList<'a>>,
|
||||
/// The domain registrant
|
||||
#[serde(rename = "domain:registrant")]
|
||||
pub registrant: Option<StringValue>,
|
||||
pub registrant: Option<StringValue<'a>>,
|
||||
/// The list of contacts for the domain
|
||||
#[serde(rename = "domain:contact")]
|
||||
pub contacts: Option<Vec<DomainContact>>,
|
||||
/// The auth info for the domain
|
||||
#[serde(rename = "domain:authInfo")]
|
||||
pub auth_info: DomainAuthInfo,
|
||||
pub auth_info: DomainAuthInfo<'a>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
/// Type for EPP XML <create> command for domains
|
||||
pub struct DomainCreate {
|
||||
pub struct DomainCreate<'a> {
|
||||
/// The data for the domain to be created with
|
||||
/// T being the type of nameserver list (`HostObjList` or `HostAttrList`)
|
||||
/// to be supplied
|
||||
#[serde(rename = "domain:create")]
|
||||
pub domain: DomainCreateRequestData,
|
||||
pub domain: DomainCreateRequestData<'a>,
|
||||
}
|
||||
|
||||
impl DomainCreate {
|
||||
impl<'a> DomainCreate<'a> {
|
||||
pub fn new(
|
||||
name: &str,
|
||||
name: &'a str,
|
||||
period: u16,
|
||||
ns: Option<HostList>,
|
||||
registrant_id: Option<&str>,
|
||||
auth_password: &str,
|
||||
ns: Option<HostList<'a>>,
|
||||
registrant_id: Option<&'a str>,
|
||||
auth_password: &'a str,
|
||||
contacts: Option<Vec<DomainContact>>,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
@ -84,13 +84,13 @@ pub struct DomainCreateResponseData {
|
|||
#[serde(rename = "xmlns:domain")]
|
||||
pub xmlns: String,
|
||||
/// The domain name
|
||||
pub name: StringValue,
|
||||
pub name: StringValue<'static>,
|
||||
/// The creation date
|
||||
#[serde(rename = "crDate")]
|
||||
pub created_at: StringValue,
|
||||
pub created_at: StringValue<'static>,
|
||||
/// The expiry date
|
||||
#[serde(rename = "exDate")]
|
||||
pub expiring_at: Option<StringValue>,
|
||||
pub expiring_at: Option<StringValue<'static>>,
|
||||
}
|
||||
|
||||
/// Type that represents the <resData> tag for domain create response
|
||||
|
|
|
@ -5,15 +5,15 @@ use crate::common::{NoExtension, StringValue};
|
|||
use crate::request::{Command, Transaction};
|
||||
use serde::Serialize;
|
||||
|
||||
impl Transaction<NoExtension> for DomainDelete {}
|
||||
impl<'a> Transaction<NoExtension> for DomainDelete<'a> {}
|
||||
|
||||
impl Command for DomainDelete {
|
||||
impl<'a> Command for DomainDelete<'a> {
|
||||
type Response = ();
|
||||
const COMMAND: &'static str = "delete";
|
||||
}
|
||||
|
||||
impl DomainDelete {
|
||||
pub fn new(name: &str) -> Self {
|
||||
impl<'a> DomainDelete<'a> {
|
||||
pub fn new(name: &'a str) -> Self {
|
||||
Self {
|
||||
domain: DomainDeleteRequestData {
|
||||
xmlns: XMLNS,
|
||||
|
@ -25,21 +25,21 @@ impl DomainDelete {
|
|||
|
||||
/// Type for <name> element under the domain <delete> tag
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct DomainDeleteRequestData {
|
||||
pub struct DomainDeleteRequestData<'a> {
|
||||
/// XML namespace for domain commands
|
||||
#[serde(rename = "xmlns:domain")]
|
||||
xmlns: &'static str,
|
||||
xmlns: &'a str,
|
||||
/// The domain to be deleted
|
||||
#[serde(rename = "domain:name")]
|
||||
name: StringValue,
|
||||
name: StringValue<'a>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
/// Type for EPP XML <delete> command for domains
|
||||
pub struct DomainDelete {
|
||||
pub struct DomainDelete<'a> {
|
||||
/// The data under the <delete> tag for domain deletion
|
||||
#[serde(rename = "domain:delete")]
|
||||
domain: DomainDeleteRequestData,
|
||||
domain: DomainDeleteRequestData<'a>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -5,15 +5,15 @@ use crate::common::{NoExtension, ObjectStatus, StringValue};
|
|||
use crate::request::{Command, Transaction};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
impl Transaction<NoExtension> for DomainInfo {}
|
||||
impl<'a> Transaction<NoExtension> for DomainInfo<'a> {}
|
||||
|
||||
impl Command for DomainInfo {
|
||||
impl<'a> Command for DomainInfo<'a> {
|
||||
type Response = DomainInfoResponse;
|
||||
const COMMAND: &'static str = "info";
|
||||
}
|
||||
|
||||
impl DomainInfo {
|
||||
pub fn new(name: &str, auth_password: Option<&str>) -> Self {
|
||||
impl<'a> DomainInfo<'a> {
|
||||
pub fn new(name: &'a str, auth_password: Option<&'a str>) -> Self {
|
||||
Self {
|
||||
info: DomainInfoRequestData {
|
||||
xmlns: XMLNS,
|
||||
|
@ -43,24 +43,24 @@ pub struct Domain {
|
|||
|
||||
/// Type for <name> element under the domain <info> tag
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct DomainInfoRequestData {
|
||||
pub struct DomainInfoRequestData<'a> {
|
||||
/// XML namespace for domain commands
|
||||
#[serde(rename = "xmlns:domain")]
|
||||
xmlns: &'static str,
|
||||
xmlns: &'a str,
|
||||
/// The data for the domain to be queried
|
||||
#[serde(rename = "domain:name")]
|
||||
domain: Domain,
|
||||
/// The auth info for the domain
|
||||
#[serde(rename = "domain:authInfo")]
|
||||
auth_info: Option<DomainAuthInfo>,
|
||||
auth_info: Option<DomainAuthInfo<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
/// Type for EPP XML <info> command for domains
|
||||
pub struct DomainInfo {
|
||||
pub struct DomainInfo<'a> {
|
||||
/// The data under the <info> tag for domain info
|
||||
#[serde(rename = "domain:info")]
|
||||
info: DomainInfoRequestData,
|
||||
info: DomainInfoRequestData<'a>,
|
||||
}
|
||||
|
||||
// Response
|
||||
|
@ -71,23 +71,23 @@ pub struct DomainInfo {
|
|||
pub struct DomainNsList {
|
||||
/// List of <hostObj> ns elements
|
||||
#[serde(rename = "hostObj")]
|
||||
pub host_obj: Option<Vec<StringValue>>,
|
||||
pub host_obj: Option<Vec<StringValue<'static>>>,
|
||||
/// List of <hostAttr> ns elements
|
||||
pub host_attr: Option<Vec<HostAttr>>,
|
||||
pub host_attr: Option<Vec<HostAttr<'static>>>,
|
||||
}
|
||||
|
||||
/// Type that represents the <infData> tag for domain info response
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct DomainInfoResponseData {
|
||||
/// The domain name
|
||||
pub name: StringValue,
|
||||
pub name: StringValue<'static>,
|
||||
/// The domain ROID
|
||||
pub roid: StringValue,
|
||||
pub roid: StringValue<'static>,
|
||||
/// The list of domain statuses
|
||||
#[serde(rename = "status")]
|
||||
pub statuses: Option<Vec<ObjectStatus>>,
|
||||
/// The domain registrant
|
||||
pub registrant: Option<StringValue>,
|
||||
pub registrant: Option<StringValue<'static>>,
|
||||
/// The list of domain contacts
|
||||
#[serde(rename = "contact")]
|
||||
pub contacts: Option<Vec<DomainContact>>,
|
||||
|
@ -96,31 +96,31 @@ pub struct DomainInfoResponseData {
|
|||
pub ns: Option<DomainNsList>,
|
||||
/// The list of domain hosts
|
||||
#[serde(rename = "host")]
|
||||
pub hosts: Option<Vec<StringValue>>,
|
||||
pub hosts: Option<Vec<StringValue<'static>>>,
|
||||
/// The epp user who owns the domain
|
||||
#[serde(rename = "clID")]
|
||||
pub client_id: StringValue,
|
||||
pub client_id: StringValue<'static>,
|
||||
/// The epp user who created the domain
|
||||
#[serde(rename = "crID")]
|
||||
pub creator_id: Option<StringValue>,
|
||||
pub creator_id: Option<StringValue<'static>>,
|
||||
/// The domain creation date
|
||||
#[serde(rename = "crDate")]
|
||||
pub created_at: Option<StringValue>,
|
||||
pub created_at: Option<StringValue<'static>>,
|
||||
/// The domain expiry date
|
||||
#[serde(rename = "exDate")]
|
||||
pub expiring_at: Option<StringValue>,
|
||||
pub expiring_at: Option<StringValue<'static>>,
|
||||
/// The epp user who last updated the domain
|
||||
#[serde(rename = "upID")]
|
||||
pub updater_id: Option<StringValue>,
|
||||
pub updater_id: Option<StringValue<'static>>,
|
||||
/// The domain last updated date
|
||||
#[serde(rename = "upDate")]
|
||||
pub updated_at: Option<StringValue>,
|
||||
pub updated_at: Option<StringValue<'static>>,
|
||||
/// The domain transfer date
|
||||
#[serde(rename = "trDate")]
|
||||
pub transferred_at: Option<StringValue>,
|
||||
pub transferred_at: Option<StringValue<'static>>,
|
||||
/// The domain auth info
|
||||
#[serde(rename = "authInfo")]
|
||||
pub auth_info: Option<DomainAuthInfo>,
|
||||
pub auth_info: Option<DomainAuthInfo<'static>>,
|
||||
}
|
||||
|
||||
/// Type that represents the <resData> tag for domain info response
|
||||
|
|
|
@ -6,15 +6,15 @@ use crate::request::{Command, Transaction};
|
|||
use chrono::NaiveDate;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
impl Transaction<NoExtension> for DomainRenew {}
|
||||
impl<'a> Transaction<NoExtension> for DomainRenew<'a> {}
|
||||
|
||||
impl Command for DomainRenew {
|
||||
impl<'a> Command for DomainRenew<'a> {
|
||||
type Response = DomainRenewResponse;
|
||||
const COMMAND: &'static str = "renew";
|
||||
}
|
||||
|
||||
impl DomainRenew {
|
||||
pub fn new(name: &str, current_expiry_date: NaiveDate, years: u16) -> Self {
|
||||
impl<'a> DomainRenew<'a> {
|
||||
pub fn new(name: &'a str, current_expiry_date: NaiveDate, years: u16) -> Self {
|
||||
let exp_date_str = current_expiry_date.format("%Y-%m-%d").to_string().into();
|
||||
Self {
|
||||
domain: DomainRenewRequestData {
|
||||
|
@ -31,16 +31,16 @@ impl DomainRenew {
|
|||
|
||||
/// Type for data under the domain <renew> tag
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct DomainRenewRequestData {
|
||||
pub struct DomainRenewRequestData<'a> {
|
||||
/// XML namespace for domain commands
|
||||
#[serde(rename = "xmlns:domain")]
|
||||
xmlns: &'static str,
|
||||
xmlns: &'a str,
|
||||
/// The name of the domain to be renewed
|
||||
#[serde(rename = "domain:name")]
|
||||
name: StringValue,
|
||||
name: StringValue<'a>,
|
||||
/// The current expiry date of the domain in 'Y-m-d' format
|
||||
#[serde(rename = "domain:curExpDate")]
|
||||
current_expiry_date: StringValue,
|
||||
current_expiry_date: StringValue<'a>,
|
||||
/// The period of renewal
|
||||
#[serde(rename = "domain:period")]
|
||||
period: Period,
|
||||
|
@ -48,10 +48,10 @@ pub struct DomainRenewRequestData {
|
|||
|
||||
#[derive(Serialize, Debug)]
|
||||
/// Type for EPP XML <renew> command for domains
|
||||
pub struct DomainRenew {
|
||||
pub struct DomainRenew<'a> {
|
||||
/// The data under the <renew> tag for the domain renewal
|
||||
#[serde(rename = "domain:renew")]
|
||||
domain: DomainRenewRequestData,
|
||||
domain: DomainRenewRequestData<'a>,
|
||||
}
|
||||
|
||||
// Response
|
||||
|
@ -60,10 +60,10 @@ pub struct DomainRenew {
|
|||
#[derive(Deserialize, Debug)]
|
||||
pub struct DomainRenewResponseData {
|
||||
/// The name of the domain
|
||||
pub name: StringValue,
|
||||
pub name: StringValue<'static>,
|
||||
/// The new expiry date after renewal
|
||||
#[serde(rename = "exDate")]
|
||||
pub expiring_at: Option<StringValue>,
|
||||
pub expiring_at: Option<StringValue<'static>>,
|
||||
}
|
||||
|
||||
/// Type that represents the <resData> tag for domain renew response
|
||||
|
|
|
@ -5,15 +5,15 @@ use crate::common::{NoExtension, StringValue};
|
|||
use crate::request::{Command, Transaction};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
impl Transaction<NoExtension> for DomainTransfer {}
|
||||
impl<'a> Transaction<NoExtension> for DomainTransfer<'a> {}
|
||||
|
||||
impl Command for DomainTransfer {
|
||||
impl<'a> Command for DomainTransfer<'a> {
|
||||
type Response = DomainTransferResponse;
|
||||
const COMMAND: &'static str = "transfer";
|
||||
}
|
||||
|
||||
impl DomainTransfer {
|
||||
pub fn new(name: &str, years: Option<u16>, auth_password: &str) -> Self {
|
||||
impl<'a> DomainTransfer<'a> {
|
||||
pub fn new(name: &'a str, years: Option<u16>, auth_password: &'a str) -> Self {
|
||||
Self::build(
|
||||
"request",
|
||||
name,
|
||||
|
@ -22,7 +22,7 @@ impl DomainTransfer {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn query(name: &str, auth_password: &str) -> Self {
|
||||
pub fn query(name: &'a str, auth_password: &'a str) -> Self {
|
||||
Self::build(
|
||||
"query",
|
||||
name,
|
||||
|
@ -31,23 +31,23 @@ impl DomainTransfer {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn approve(name: &str) -> Self {
|
||||
pub fn approve(name: &'a str) -> Self {
|
||||
Self::build("approve", name, None, None)
|
||||
}
|
||||
|
||||
pub fn reject(name: &str) -> Self {
|
||||
pub fn reject(name: &'a str) -> Self {
|
||||
Self::build("reject", name, None, None)
|
||||
}
|
||||
|
||||
pub fn cancel(name: &str) -> Self {
|
||||
pub fn cancel(name: &'a str) -> Self {
|
||||
Self::build("cancel", name, None, None)
|
||||
}
|
||||
|
||||
fn build(
|
||||
operation: &str,
|
||||
name: &str,
|
||||
operation: &'a str,
|
||||
name: &'a str,
|
||||
period: Option<Period>,
|
||||
auth_info: Option<DomainAuthInfo>,
|
||||
auth_info: Option<DomainAuthInfo<'a>>,
|
||||
) -> Self {
|
||||
Self {
|
||||
operation: operation.to_string(),
|
||||
|
@ -65,13 +65,13 @@ impl DomainTransfer {
|
|||
|
||||
/// Type for elements under the domain <transfer> tag
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct DomainTransferReqData {
|
||||
pub struct DomainTransferReqData<'a> {
|
||||
/// XML namespace for domain commands
|
||||
#[serde(rename = "xmlns:domain")]
|
||||
xmlns: &'static str,
|
||||
xmlns: &'a str,
|
||||
/// The name of the domain under transfer
|
||||
#[serde(rename = "domain:name")]
|
||||
name: StringValue,
|
||||
name: StringValue<'a>,
|
||||
/// The period of renewal upon a successful transfer
|
||||
/// Only applicable in case of a transfer request
|
||||
#[serde(rename = "domain:period")]
|
||||
|
@ -79,19 +79,19 @@ pub struct DomainTransferReqData {
|
|||
/// The authInfo for the domain under transfer
|
||||
/// Only applicable to domain transfer and domain transfer query requests
|
||||
#[serde(rename = "domain:authInfo")]
|
||||
auth_info: Option<DomainAuthInfo>,
|
||||
auth_info: Option<DomainAuthInfo<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
/// Type for EPP XML <transfer> command for domains
|
||||
pub struct DomainTransfer {
|
||||
pub struct DomainTransfer<'a> {
|
||||
/// The transfer operation to perform indicated by the 'op' attr
|
||||
/// The values are one of transfer or query
|
||||
#[serde(rename = "op")]
|
||||
operation: String,
|
||||
/// The data under the <transfer> tag in the transfer request
|
||||
#[serde(rename = "domain:transfer")]
|
||||
domain: DomainTransferReqData,
|
||||
domain: DomainTransferReqData<'a>,
|
||||
}
|
||||
|
||||
// Response
|
||||
|
@ -100,25 +100,25 @@ pub struct DomainTransfer {
|
|||
#[derive(Deserialize, Debug)]
|
||||
pub struct DomainTransferResponseData {
|
||||
/// The domain name
|
||||
pub name: StringValue,
|
||||
pub name: StringValue<'static>,
|
||||
/// The domain transfer status
|
||||
#[serde(rename = "trStatus")]
|
||||
pub transfer_status: StringValue,
|
||||
pub transfer_status: StringValue<'static>,
|
||||
/// The epp user who requested the transfer
|
||||
#[serde(rename = "reID")]
|
||||
pub requester_id: StringValue,
|
||||
pub requester_id: StringValue<'static>,
|
||||
/// The transfer rquest date
|
||||
#[serde(rename = "reDate")]
|
||||
pub requested_at: StringValue,
|
||||
pub requested_at: StringValue<'static>,
|
||||
/// The epp user who should acknowledge the transfer request
|
||||
#[serde(rename = "acID")]
|
||||
pub ack_id: StringValue,
|
||||
pub ack_id: StringValue<'static>,
|
||||
/// THe date by which the acknowledgment should be made
|
||||
#[serde(rename = "acDate")]
|
||||
pub ack_by: StringValue,
|
||||
pub ack_by: StringValue<'static>,
|
||||
/// The domain expiry date
|
||||
#[serde(rename = "exDate")]
|
||||
pub expiring_at: Option<StringValue>,
|
||||
pub expiring_at: Option<StringValue<'static>>,
|
||||
}
|
||||
|
||||
/// Type that represents the <resData> tag for domain transfer response
|
||||
|
|
|
@ -8,15 +8,15 @@ use crate::{
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
impl Transaction<NoExtension> for DomainUpdate {}
|
||||
impl<'a> Transaction<NoExtension> for DomainUpdate<'a> {}
|
||||
|
||||
impl Command for DomainUpdate {
|
||||
impl<'a> Command for DomainUpdate<'a> {
|
||||
type Response = ();
|
||||
const COMMAND: &'static str = "update";
|
||||
}
|
||||
|
||||
impl DomainUpdate {
|
||||
pub fn new(name: &str) -> Self {
|
||||
impl<'a> DomainUpdate<'a> {
|
||||
pub fn new(name: &'a str) -> Self {
|
||||
Self {
|
||||
domain: DomainUpdateRequestData {
|
||||
xmlns: XMLNS,
|
||||
|
@ -29,39 +29,39 @@ impl DomainUpdate {
|
|||
}
|
||||
|
||||
/// Sets the data for the <chg> tag
|
||||
pub fn info(&mut self, info: DomainChangeInfo) {
|
||||
pub fn info(&mut self, info: DomainChangeInfo<'a>) {
|
||||
self.domain.change_info = Some(info);
|
||||
}
|
||||
|
||||
/// Sets the data for the <add> tag
|
||||
pub fn add(&mut self, add: DomainAddRemove) {
|
||||
pub fn add(&mut self, add: DomainAddRemove<'a>) {
|
||||
self.domain.add = Some(add);
|
||||
}
|
||||
|
||||
/// Sets the data for the <rem> tag
|
||||
pub fn remove(&mut self, remove: DomainAddRemove) {
|
||||
pub fn remove(&mut self, remove: DomainAddRemove<'a>) {
|
||||
self.domain.remove = Some(remove);
|
||||
}
|
||||
}
|
||||
|
||||
/// Type for elements under the <chg> tag for domain update
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct DomainChangeInfo {
|
||||
pub struct DomainChangeInfo<'a> {
|
||||
/// The new registrant contact for the domain
|
||||
#[serde(rename = "domain:registrant")]
|
||||
pub registrant: Option<StringValue>,
|
||||
pub registrant: Option<StringValue<'a>>,
|
||||
/// The new auth info for the domain
|
||||
#[serde(rename = "domain:authInfo")]
|
||||
pub auth_info: Option<DomainAuthInfo>,
|
||||
pub auth_info: Option<DomainAuthInfo<'a>>,
|
||||
}
|
||||
|
||||
/// Type for elements under the <add> and <rem> tags for domain update
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct DomainAddRemove {
|
||||
pub struct DomainAddRemove<'a> {
|
||||
/// The list of nameservers to add or remove
|
||||
/// Type T can be either a `HostObjList` or `HostAttrList`
|
||||
#[serde(rename = "domain:ns")]
|
||||
pub ns: Option<HostList>,
|
||||
pub ns: Option<HostList<'a>>,
|
||||
/// The list of contacts to add to or remove from the domain
|
||||
#[serde(rename = "domain:contact")]
|
||||
pub contacts: Option<Vec<DomainContact>>,
|
||||
|
@ -72,31 +72,31 @@ pub struct DomainAddRemove {
|
|||
|
||||
/// Type for elements under the <update> tag for domain update
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct DomainUpdateRequestData {
|
||||
pub struct DomainUpdateRequestData<'a> {
|
||||
/// XML namespace for domain commands
|
||||
#[serde(rename = "xmlns:domain")]
|
||||
pub xmlns: &'static str,
|
||||
pub xmlns: &'a str,
|
||||
/// The name of the domain to update
|
||||
#[serde(rename = "domain:name")]
|
||||
pub name: StringValue,
|
||||
pub name: StringValue<'a>,
|
||||
/// `DomainAddRemove` Object containing the list of elements to be added
|
||||
/// to the domain
|
||||
#[serde(rename = "domain:add")]
|
||||
pub add: Option<DomainAddRemove>,
|
||||
pub add: Option<DomainAddRemove<'a>>,
|
||||
/// `DomainAddRemove` Object containing the list of elements to be removed
|
||||
/// from the domain
|
||||
#[serde(rename = "domain:rem")]
|
||||
pub remove: Option<DomainAddRemove>,
|
||||
pub remove: Option<DomainAddRemove<'a>>,
|
||||
/// The data under the <chg> tag for domain update
|
||||
#[serde(rename = "domain:chg")]
|
||||
pub change_info: Option<DomainChangeInfo>,
|
||||
pub change_info: Option<DomainChangeInfo<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
/// Type for EPP XML <update> command for domains
|
||||
pub struct DomainUpdate {
|
||||
pub struct DomainUpdate<'a> {
|
||||
#[serde(rename = "domain:update")]
|
||||
pub domain: DomainUpdateRequestData,
|
||||
pub domain: DomainUpdateRequestData<'a>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::request::{Extension, Transaction};
|
|||
|
||||
pub const XMLNS: &str = "http://www.verisign.com/epp/sync-1.0";
|
||||
|
||||
impl Transaction<Update> for DomainUpdate {}
|
||||
impl<'a> Transaction<Update> for DomainUpdate<'a> {}
|
||||
|
||||
impl Extension for Update {
|
||||
type Response = NoExtension;
|
||||
|
@ -84,7 +84,7 @@ pub struct UpdateData {
|
|||
pub xmlns: &'static str,
|
||||
/// The expiry date of the domain
|
||||
#[serde(rename = "sync:expMonthDay")]
|
||||
pub exp: StringValue,
|
||||
pub exp: StringValue<'static>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -23,29 +23,29 @@ pub const XMLNS: &str = "http://www.verisign-grs.com/epp/namestoreExt-1.1";
|
|||
|
||||
// Contact
|
||||
|
||||
impl Transaction<NameStore> for ContactCheck {}
|
||||
impl Transaction<NameStore> for ContactCreate {}
|
||||
impl Transaction<NameStore> for ContactDelete {}
|
||||
impl Transaction<NameStore> for ContactInfo {}
|
||||
impl Transaction<NameStore> for ContactUpdate {}
|
||||
impl<'a> Transaction<NameStore> for ContactCheck<'a> {}
|
||||
impl<'a> Transaction<NameStore> for ContactCreate<'a> {}
|
||||
impl<'a> Transaction<NameStore> for ContactDelete<'a> {}
|
||||
impl<'a> Transaction<NameStore> for ContactInfo<'a> {}
|
||||
impl<'a> Transaction<NameStore> for ContactUpdate<'a> {}
|
||||
|
||||
// Domain
|
||||
|
||||
impl Transaction<NameStore> for DomainCheck {}
|
||||
impl Transaction<NameStore> for DomainCreate {}
|
||||
impl Transaction<NameStore> for DomainDelete {}
|
||||
impl Transaction<NameStore> for DomainInfo {}
|
||||
impl Transaction<NameStore> for DomainRenew {}
|
||||
impl Transaction<NameStore> for DomainTransfer {}
|
||||
impl Transaction<NameStore> for DomainUpdate {}
|
||||
impl<'a> Transaction<NameStore> for DomainCheck<'a> {}
|
||||
impl<'a> Transaction<NameStore> for DomainCreate<'a> {}
|
||||
impl<'a> Transaction<NameStore> for DomainDelete<'a> {}
|
||||
impl<'a> Transaction<NameStore> for DomainInfo<'a> {}
|
||||
impl<'a> Transaction<NameStore> for DomainRenew<'a> {}
|
||||
impl<'a> Transaction<NameStore> for DomainTransfer<'a> {}
|
||||
impl<'a> Transaction<NameStore> for DomainUpdate<'a> {}
|
||||
|
||||
// Host
|
||||
|
||||
impl Transaction<NameStore> for HostCheck {}
|
||||
impl Transaction<NameStore> for HostCreate {}
|
||||
impl Transaction<NameStore> for HostDelete {}
|
||||
impl Transaction<NameStore> for HostInfo {}
|
||||
impl Transaction<NameStore> for HostUpdate {}
|
||||
impl<'a> Transaction<NameStore> for HostCheck<'a> {}
|
||||
impl<'a> Transaction<NameStore> for HostCreate<'a> {}
|
||||
impl<'a> Transaction<NameStore> for HostDelete<'a> {}
|
||||
impl<'a> Transaction<NameStore> for HostInfo<'a> {}
|
||||
impl<'a> Transaction<NameStore> for HostUpdate<'a> {}
|
||||
|
||||
impl NameStore {
|
||||
/// Create a new RGP restore report request
|
||||
|
@ -53,7 +53,7 @@ impl NameStore {
|
|||
NameStore {
|
||||
data: NameStoreData {
|
||||
xmlns: XMLNS.to_string(),
|
||||
subproduct: subproduct.into(),
|
||||
subproduct: subproduct.to_owned().into(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ pub struct NameStoreData {
|
|||
pub xmlns: String,
|
||||
/// The object holding the list of domains to be checked
|
||||
#[serde(rename = "namestoreExt:subProduct", alias = "subProduct")]
|
||||
pub subproduct: StringValue,
|
||||
pub subproduct: StringValue<'static>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -8,22 +8,22 @@ use serde::Serialize;
|
|||
|
||||
use super::{Update, XMLNS};
|
||||
|
||||
impl Transaction<Update<RgpRestoreReport>> for DomainUpdate {}
|
||||
impl<'a> Transaction<Update<RgpRestoreReport<'a>>> for DomainUpdate<'a> {}
|
||||
|
||||
impl RgpRestoreReport {
|
||||
impl<'a> RgpRestoreReport<'a> {
|
||||
/// Create a new RGP restore report request
|
||||
pub fn new(
|
||||
pre_data: &str,
|
||||
post_data: &str,
|
||||
pre_data: &'a str,
|
||||
post_data: &'a str,
|
||||
deleted_at: DateTime<Utc>,
|
||||
restored_at: DateTime<Utc>,
|
||||
restore_reason: &str,
|
||||
statements: &[&str],
|
||||
other: &str,
|
||||
) -> RgpRestoreReport {
|
||||
restore_reason: &'a str,
|
||||
statements: &[&'a str],
|
||||
other: &'a str,
|
||||
) -> Self {
|
||||
let statements = statements.iter().map(|&s| s.into()).collect();
|
||||
|
||||
RgpRestoreReport {
|
||||
Self {
|
||||
xmlns: XMLNS,
|
||||
restore: RgpRestoreReportSection {
|
||||
op: "report".to_string(),
|
||||
|
@ -45,55 +45,55 @@ impl RgpRestoreReport {
|
|||
}
|
||||
}
|
||||
|
||||
impl Extension for Update<RgpRestoreReport> {
|
||||
impl<'a> Extension for Update<RgpRestoreReport<'a>> {
|
||||
type Response = NoExtension;
|
||||
}
|
||||
|
||||
/// Type corresponding to the <report> section in the EPP rgp restore extension
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct RgpRestoreReportSectionData {
|
||||
pub struct RgpRestoreReportSectionData<'a> {
|
||||
/// The pre-delete registration date
|
||||
#[serde(rename = "rgp:preData")]
|
||||
pre_data: StringValue,
|
||||
pre_data: StringValue<'a>,
|
||||
/// The post-delete registration date
|
||||
#[serde(rename = "rgp:postData")]
|
||||
post_data: StringValue,
|
||||
post_data: StringValue<'a>,
|
||||
/// The domain deletion date
|
||||
#[serde(rename = "rgp:delTime")]
|
||||
deleted_at: StringValue,
|
||||
deleted_at: StringValue<'a>,
|
||||
/// The domain restore request date
|
||||
#[serde(rename = "rgp:resTime")]
|
||||
restored_at: StringValue,
|
||||
restored_at: StringValue<'a>,
|
||||
/// The reason for domain restoration
|
||||
#[serde(rename = "rgp:resReason")]
|
||||
restore_reason: StringValue,
|
||||
restore_reason: StringValue<'a>,
|
||||
/// The registrar's statements on the domain restoration
|
||||
#[serde(rename = "rgp:statement")]
|
||||
statements: Vec<StringValue>,
|
||||
statements: Vec<StringValue<'a>>,
|
||||
/// Other remarks for domain restoration
|
||||
#[serde(rename = "rgp:other")]
|
||||
other: StringValue,
|
||||
other: StringValue<'a>,
|
||||
}
|
||||
|
||||
/// Type corresponding to the <restore> section in the rgp restore extension
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct RgpRestoreReportSection {
|
||||
pub struct RgpRestoreReportSection<'a> {
|
||||
/// The value of the op attribute for the <restore> tag
|
||||
op: String,
|
||||
/// Data for the <report> tag
|
||||
#[serde(rename = "rgp:report")]
|
||||
report: RgpRestoreReportSectionData,
|
||||
report: RgpRestoreReportSectionData<'a>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
/// Type for EPP XML <check> command for domains
|
||||
pub struct RgpRestoreReport {
|
||||
pub struct RgpRestoreReport<'a> {
|
||||
/// XML namespace for the RGP restore extension
|
||||
#[serde(rename = "xmlns:rgp")]
|
||||
xmlns: &'static str,
|
||||
xmlns: &'a str,
|
||||
/// The object holding the list of domains to be checked
|
||||
#[serde(rename = "rgp:restore")]
|
||||
restore: RgpRestoreReportSection,
|
||||
restore: RgpRestoreReportSection<'a>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -9,9 +9,9 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
use super::{Update, XMLNS};
|
||||
|
||||
impl Transaction<Update<RgpRestoreRequest>> for DomainUpdate {}
|
||||
impl<'a> Transaction<Update<RgpRestoreRequest>> for DomainUpdate<'a> {}
|
||||
|
||||
impl Transaction<Update<RgpRestoreRequest>> for DomainInfo {}
|
||||
impl<'a> Transaction<Update<RgpRestoreRequest>> for DomainInfo<'a> {}
|
||||
|
||||
impl Extension for Update<RgpRestoreRequest> {
|
||||
type Response = Update<RgpRequestResponse>;
|
||||
|
|
18
src/hello.rs
18
src/hello.rs
|
@ -33,22 +33,22 @@ impl EppXml for HelloDocument {}
|
|||
/// Type for data within the <svcMenu> section of an EPP greeting
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct ServiceMenu {
|
||||
pub options: Options,
|
||||
pub services: Services,
|
||||
pub options: Options<'static>,
|
||||
pub services: Services<'static>,
|
||||
}
|
||||
|
||||
/// Simplified service menu type for deserialization to `ServiceMenu` type from EPP greeting XML
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
struct FlattenedServiceMenu {
|
||||
pub version: StringValue,
|
||||
pub lang: StringValue,
|
||||
pub version: StringValue<'static>,
|
||||
pub lang: StringValue<'static>,
|
||||
#[serde(rename = "objURI")]
|
||||
pub obj_uris: Vec<StringValue>,
|
||||
pub obj_uris: Vec<StringValue<'static>>,
|
||||
#[serde(rename = "svcExtension")]
|
||||
pub svc_ext: Option<ServiceExtension>,
|
||||
pub svc_ext: Option<ServiceExtension<'static>>,
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for ServiceMenu {
|
||||
impl<'a, 'de: 'a> Deserialize<'de> for ServiceMenu {
|
||||
/// Deserializes the <svcMenu> data to the `ServiceMenu` type
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
|
@ -238,14 +238,14 @@ pub struct Statement {
|
|||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
pub struct Absolute {
|
||||
#[serde(rename = "$value")]
|
||||
pub absolute: StringValue,
|
||||
pub absolute: StringValue<'static>,
|
||||
}
|
||||
|
||||
/// Type corresponding to <relative> value in the EPP greeting XML
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
pub struct Relative {
|
||||
#[serde(rename = "$value")]
|
||||
pub relative: StringValue,
|
||||
pub relative: StringValue<'static>,
|
||||
}
|
||||
|
||||
/// Type corresponding to possible <expiry> type values
|
||||
|
|
|
@ -7,15 +7,15 @@ use crate::common::{NoExtension, StringValue};
|
|||
use crate::request::{Command, Transaction};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
impl Transaction<NoExtension> for HostCheck {}
|
||||
impl<'a> Transaction<NoExtension> for HostCheck<'a> {}
|
||||
|
||||
impl Command for HostCheck {
|
||||
impl<'a> Command for HostCheck<'a> {
|
||||
type Response = HostCheckResponse;
|
||||
const COMMAND: &'static str = "check";
|
||||
}
|
||||
|
||||
impl HostCheck {
|
||||
pub fn new(hosts: &[&str]) -> Self {
|
||||
impl<'a> HostCheck<'a> {
|
||||
pub fn new(hosts: &[&'a str]) -> Self {
|
||||
let hosts = hosts.iter().map(|&d| d.into()).collect();
|
||||
|
||||
Self {
|
||||
|
@ -31,21 +31,21 @@ impl HostCheck {
|
|||
|
||||
/// Type for data under the host <check> tag
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct HostList {
|
||||
pub struct HostList<'a> {
|
||||
/// XML namespace for host commands
|
||||
#[serde(rename = "xmlns:host")]
|
||||
xmlns: &'static str,
|
||||
xmlns: &'a str,
|
||||
/// List of hosts to be checked for availability
|
||||
#[serde(rename = "host:name")]
|
||||
pub hosts: Vec<StringValue>,
|
||||
pub hosts: Vec<StringValue<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
/// Type for EPP XML <check> command for hosts
|
||||
pub struct HostCheck {
|
||||
pub struct HostCheck<'a> {
|
||||
/// The instance holding the list of hosts to be checked
|
||||
#[serde(rename = "host:check")]
|
||||
list: HostList,
|
||||
list: HostList<'a>,
|
||||
}
|
||||
|
||||
// Response
|
||||
|
@ -55,7 +55,7 @@ pub struct HostCheck {
|
|||
pub struct HostAvailable {
|
||||
/// The host name
|
||||
#[serde(rename = "$value")]
|
||||
pub name: StringValue,
|
||||
pub name: StringValue<'static>,
|
||||
/// The host (un)availability
|
||||
#[serde(rename = "avail")]
|
||||
pub available: u16,
|
||||
|
@ -68,7 +68,7 @@ pub struct HostCheckDataItem {
|
|||
#[serde(rename = "name")]
|
||||
pub host: HostAvailable,
|
||||
/// The reason for (un)availability
|
||||
pub reason: Option<StringValue>,
|
||||
pub reason: Option<StringValue<'static>>,
|
||||
}
|
||||
|
||||
/// Type that represents the <chkData> tag for host check response
|
||||
|
|
|
@ -5,15 +5,15 @@ use crate::common::{HostAddr, NoExtension, StringValue};
|
|||
use crate::request::{Command, Transaction};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
impl Transaction<NoExtension> for HostCreate {}
|
||||
impl<'a> Transaction<NoExtension> for HostCreate<'a> {}
|
||||
|
||||
impl Command for HostCreate {
|
||||
impl<'a> Command for HostCreate<'a> {
|
||||
type Response = HostCreateResponse;
|
||||
const COMMAND: &'static str = "create";
|
||||
}
|
||||
|
||||
impl HostCreate {
|
||||
pub fn new(host: &str, addresses: Vec<HostAddr>) -> Self {
|
||||
impl<'a> HostCreate<'a> {
|
||||
pub fn new(host: &'a str, addresses: Vec<HostAddr>) -> Self {
|
||||
Self {
|
||||
host: HostCreateRequestData {
|
||||
xmlns: XMLNS,
|
||||
|
@ -28,13 +28,13 @@ impl HostCreate {
|
|||
|
||||
/// Type for data under the host <create> tag
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct HostCreateRequestData {
|
||||
pub struct HostCreateRequestData<'a> {
|
||||
/// XML namespace for host commands
|
||||
#[serde(rename = "xmlns:host")]
|
||||
xmlns: &'static str,
|
||||
xmlns: &'a str,
|
||||
/// The name of the host to be created
|
||||
#[serde(rename = "host:name")]
|
||||
pub name: StringValue,
|
||||
pub name: StringValue<'a>,
|
||||
/// The list of IP addresses for the host
|
||||
#[serde(rename = "host:addr")]
|
||||
pub addresses: Option<Vec<HostAddr>>,
|
||||
|
@ -42,10 +42,10 @@ pub struct HostCreateRequestData {
|
|||
|
||||
#[derive(Serialize, Debug)]
|
||||
/// Type for EPP XML <create> command for hosts
|
||||
pub struct HostCreate {
|
||||
pub struct HostCreate<'a> {
|
||||
/// The instance holding the data for the host to be created
|
||||
#[serde(rename = "host:create")]
|
||||
host: HostCreateRequestData,
|
||||
host: HostCreateRequestData<'a>,
|
||||
}
|
||||
|
||||
// Response
|
||||
|
@ -54,10 +54,10 @@ pub struct HostCreate {
|
|||
#[derive(Deserialize, Debug)]
|
||||
pub struct HostCreateData {
|
||||
/// The host name
|
||||
pub name: StringValue,
|
||||
pub name: StringValue<'static>,
|
||||
/// The host creation date
|
||||
#[serde(rename = "crDate")]
|
||||
pub created_at: StringValue,
|
||||
pub created_at: StringValue<'static>,
|
||||
}
|
||||
|
||||
/// Type that represents the <resData> tag for host check response
|
||||
|
|
|
@ -5,15 +5,15 @@ use crate::common::{NoExtension, StringValue};
|
|||
use crate::request::{Command, Transaction};
|
||||
use serde::Serialize;
|
||||
|
||||
impl Transaction<NoExtension> for HostDelete {}
|
||||
impl<'a> Transaction<NoExtension> for HostDelete<'a> {}
|
||||
|
||||
impl Command for HostDelete {
|
||||
impl<'a> Command for HostDelete<'a> {
|
||||
type Response = ();
|
||||
const COMMAND: &'static str = "delete";
|
||||
}
|
||||
|
||||
impl HostDelete {
|
||||
pub fn new(name: &str) -> Self {
|
||||
impl<'a> HostDelete<'a> {
|
||||
pub fn new(name: &'a str) -> Self {
|
||||
Self {
|
||||
host: HostDeleteRequestData {
|
||||
xmlns: XMLNS,
|
||||
|
@ -25,21 +25,21 @@ impl HostDelete {
|
|||
|
||||
/// Type for data under the host <delete> tag
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct HostDeleteRequestData {
|
||||
pub struct HostDeleteRequestData<'a> {
|
||||
/// XML namespace for host commands
|
||||
#[serde(rename = "xmlns:host")]
|
||||
xmlns: &'static str,
|
||||
xmlns: &'a str,
|
||||
/// The host to be deleted
|
||||
#[serde(rename = "host:name")]
|
||||
name: StringValue,
|
||||
name: StringValue<'a>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
/// Type for EPP XML <delete> command for hosts
|
||||
pub struct HostDelete {
|
||||
pub struct HostDelete<'a> {
|
||||
/// The instance holding the data for the host to be deleted
|
||||
#[serde(rename = "host:delete")]
|
||||
host: HostDeleteRequestData,
|
||||
host: HostDeleteRequestData<'a>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -5,15 +5,15 @@ use crate::common::{HostAddr, NoExtension, ObjectStatus, StringValue};
|
|||
use crate::request::{Command, Transaction};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
impl Transaction<NoExtension> for HostInfo {}
|
||||
impl<'a> Transaction<NoExtension> for HostInfo<'a> {}
|
||||
|
||||
impl Command for HostInfo {
|
||||
impl<'a> Command for HostInfo<'a> {
|
||||
type Response = HostInfoResponse;
|
||||
const COMMAND: &'static str = "info";
|
||||
}
|
||||
|
||||
impl HostInfo {
|
||||
pub fn new(name: &str) -> Self {
|
||||
impl<'a> HostInfo<'a> {
|
||||
pub fn new(name: &'a str) -> Self {
|
||||
Self {
|
||||
info: HostInfoRequestData {
|
||||
xmlns: XMLNS,
|
||||
|
@ -27,21 +27,21 @@ impl HostInfo {
|
|||
|
||||
/// Type for data under the host <info> tag
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct HostInfoRequestData {
|
||||
pub struct HostInfoRequestData<'a> {
|
||||
/// XML namespace for host commands
|
||||
#[serde(rename = "xmlns:host")]
|
||||
xmlns: &'static str,
|
||||
xmlns: &'a str,
|
||||
/// The name of the host to be queried
|
||||
#[serde(rename = "host:name")]
|
||||
name: StringValue,
|
||||
name: StringValue<'a>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
/// Type for EPP XML <info> command for hosts
|
||||
pub struct HostInfo {
|
||||
pub struct HostInfo<'a> {
|
||||
/// The instance holding the data for the host query
|
||||
#[serde(rename = "host:info")]
|
||||
info: HostInfoRequestData,
|
||||
info: HostInfoRequestData<'a>,
|
||||
}
|
||||
|
||||
// Response
|
||||
|
@ -50,9 +50,9 @@ pub struct HostInfo {
|
|||
#[derive(Deserialize, Debug)]
|
||||
pub struct HostInfoResponseData {
|
||||
/// The host name
|
||||
pub name: StringValue,
|
||||
pub name: StringValue<'static>,
|
||||
/// The host ROID
|
||||
pub roid: StringValue,
|
||||
pub roid: StringValue<'static>,
|
||||
/// The list of host statuses
|
||||
#[serde(rename = "status")]
|
||||
pub statuses: Vec<ObjectStatus>,
|
||||
|
@ -61,22 +61,22 @@ pub struct HostInfoResponseData {
|
|||
pub addresses: Vec<HostAddr>,
|
||||
/// The epp user to whom the host belongs
|
||||
#[serde(rename = "clID")]
|
||||
pub client_id: StringValue,
|
||||
pub client_id: StringValue<'static>,
|
||||
/// THe epp user that created the host
|
||||
#[serde(rename = "crID")]
|
||||
pub creator_id: StringValue,
|
||||
pub creator_id: StringValue<'static>,
|
||||
/// The host creation date
|
||||
#[serde(rename = "crDate")]
|
||||
pub created_at: StringValue,
|
||||
pub created_at: StringValue<'static>,
|
||||
/// The epp user that last updated the host
|
||||
#[serde(rename = "upID")]
|
||||
pub updater_id: Option<StringValue>,
|
||||
pub updater_id: Option<StringValue<'static>>,
|
||||
/// The host last update date
|
||||
#[serde(rename = "upDate")]
|
||||
pub updated_at: Option<StringValue>,
|
||||
pub updated_at: Option<StringValue<'static>>,
|
||||
/// The host transfer date
|
||||
#[serde(rename = "trDate")]
|
||||
pub transferred_at: Option<StringValue>,
|
||||
pub transferred_at: Option<StringValue<'static>>,
|
||||
}
|
||||
|
||||
/// Type that represents the <resData> tag for host info response
|
||||
|
|
|
@ -5,15 +5,15 @@ use crate::common::{HostAddr, NoExtension, ObjectStatus, StringValue};
|
|||
use crate::request::{Command, Transaction};
|
||||
use serde::Serialize;
|
||||
|
||||
impl Transaction<NoExtension> for HostUpdate {}
|
||||
impl<'a> Transaction<NoExtension> for HostUpdate<'a> {}
|
||||
|
||||
impl Command for HostUpdate {
|
||||
impl<'a> Command for HostUpdate<'a> {
|
||||
type Response = ();
|
||||
const COMMAND: &'static str = "update";
|
||||
}
|
||||
|
||||
impl HostUpdate {
|
||||
pub fn new(name: &str) -> Self {
|
||||
impl<'a> HostUpdate<'a> {
|
||||
pub fn new(name: &'a str) -> Self {
|
||||
Self {
|
||||
host: HostUpdateRequestData {
|
||||
xmlns: XMLNS,
|
||||
|
@ -26,7 +26,7 @@ impl HostUpdate {
|
|||
}
|
||||
|
||||
/// Sets the data for the <chg> element of the host update
|
||||
pub fn info(&mut self, info: HostChangeInfo) {
|
||||
pub fn info(&mut self, info: HostChangeInfo<'a>) {
|
||||
self.host.change_info = Some(info);
|
||||
}
|
||||
|
||||
|
@ -43,10 +43,10 @@ impl HostUpdate {
|
|||
|
||||
/// Type for data under the <chg> tag
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct HostChangeInfo {
|
||||
pub struct HostChangeInfo<'a> {
|
||||
/// The new name for the host
|
||||
#[serde(rename = "host:name")]
|
||||
pub name: StringValue,
|
||||
pub name: StringValue<'a>,
|
||||
}
|
||||
|
||||
/// Type for data under the <add> and <rem> tags
|
||||
|
@ -62,13 +62,13 @@ pub struct HostAddRemove {
|
|||
|
||||
/// Type for data under the host <update> tag
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct HostUpdateRequestData {
|
||||
pub struct HostUpdateRequestData<'a> {
|
||||
/// XML namespace for host commands
|
||||
#[serde(rename = "xmlns:host")]
|
||||
xmlns: &'static str,
|
||||
xmlns: &'a str,
|
||||
/// The name of the host
|
||||
#[serde(rename = "host:name")]
|
||||
name: StringValue,
|
||||
name: StringValue<'a>,
|
||||
/// The IP addresses and statuses to be added to the host
|
||||
#[serde(rename = "host:add")]
|
||||
add: Option<HostAddRemove>,
|
||||
|
@ -77,15 +77,15 @@ pub struct HostUpdateRequestData {
|
|||
remove: Option<HostAddRemove>,
|
||||
/// The host details that need to be updated
|
||||
#[serde(rename = "host:chg")]
|
||||
change_info: Option<HostChangeInfo>,
|
||||
change_info: Option<HostChangeInfo<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
/// Type for EPP XML <update> command for hosts
|
||||
pub struct HostUpdate {
|
||||
pub struct HostUpdate<'a> {
|
||||
/// The instance holding the data for the host to be updated
|
||||
#[serde(rename = "host:update")]
|
||||
host: HostUpdateRequestData,
|
||||
host: HostUpdateRequestData<'a>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
28
src/login.rs
28
src/login.rs
|
@ -8,27 +8,27 @@ use crate::{
|
|||
request::{Command, Transaction, EPP_LANG, EPP_VERSION},
|
||||
};
|
||||
|
||||
impl Transaction<NoExtension> for Login {}
|
||||
impl<'a> Transaction<NoExtension> for Login<'a> {}
|
||||
|
||||
#[derive(Serialize, Debug, PartialEq)]
|
||||
/// Type corresponding to the <login> tag in an EPP XML login request
|
||||
pub struct Login {
|
||||
pub struct Login<'a> {
|
||||
/// The username to use for the login
|
||||
#[serde(rename(serialize = "clID", deserialize = "clID"))]
|
||||
username: StringValue,
|
||||
username: StringValue<'a>,
|
||||
/// The password to use for the login
|
||||
#[serde(rename = "pw", default)]
|
||||
password: StringValue,
|
||||
password: StringValue<'a>,
|
||||
/// Data under the <options> tag
|
||||
options: Options,
|
||||
options: Options<'a>,
|
||||
/// Data under the <svcs> tag
|
||||
#[serde(rename = "svcs")]
|
||||
services: Services,
|
||||
services: Services<'a>,
|
||||
}
|
||||
|
||||
impl Login {
|
||||
pub fn new(username: &str, password: &str, ext_uris: Option<Vec<String>>) -> Self {
|
||||
let ext_uris = ext_uris.map(|uris| uris.iter().map(|u| u.as_str().into()).collect());
|
||||
impl<'a> Login<'a> {
|
||||
pub fn new(username: &'a str, password: &'a str, ext_uris: Option<Vec<&'a str>>) -> Self {
|
||||
let ext_uris = ext_uris.map(|uris| uris.into_iter().map(|u| u.into()).collect());
|
||||
|
||||
Self {
|
||||
username: username.into(),
|
||||
|
@ -49,17 +49,17 @@ impl Login {
|
|||
}
|
||||
|
||||
/// Sets the <options> tag data
|
||||
pub fn options(&mut self, options: Options) {
|
||||
pub fn options(&mut self, options: Options<'a>) {
|
||||
self.options = options;
|
||||
}
|
||||
|
||||
/// Sets the <svcs> tag data
|
||||
pub fn services(&mut self, services: Services) {
|
||||
pub fn services(&mut self, services: Services<'a>) {
|
||||
self.services = services;
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for Login {
|
||||
impl<'a> Command for Login<'a> {
|
||||
type Response = ();
|
||||
const COMMAND: &'static str = "login";
|
||||
}
|
||||
|
@ -72,9 +72,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn command() {
|
||||
let ext_uris = Some(vec![
|
||||
"http://schema.ispapi.net/epp/xml/keyvalue-1.0".to_string()
|
||||
]);
|
||||
let ext_uris = Some(vec!["http://schema.ispapi.net/epp/xml/keyvalue-1.0"]);
|
||||
|
||||
let xml = get_xml("request/login.xml").unwrap();
|
||||
let object = Login::new("username", "password", ext_uris);
|
||||
|
|
|
@ -34,25 +34,25 @@ impl Default for MessagePoll {
|
|||
pub struct MessageDomainTransferData {
|
||||
/// The name of the domain under transfer
|
||||
#[serde(rename = "domain:name", alias = "name")]
|
||||
pub name: StringValue,
|
||||
pub name: StringValue<'static>,
|
||||
/// The domain transfer status
|
||||
#[serde(rename = "domain:trStatus", alias = "trStatus")]
|
||||
pub transfer_status: StringValue,
|
||||
pub transfer_status: StringValue<'static>,
|
||||
/// The epp user who requested the transfer
|
||||
#[serde(rename = "domain:reID", alias = "reID")]
|
||||
pub requester_id: StringValue,
|
||||
pub requester_id: StringValue<'static>,
|
||||
/// The date of the transfer request
|
||||
#[serde(rename = "domain:reDate", alias = "reDate")]
|
||||
pub requested_at: StringValue,
|
||||
pub requested_at: StringValue<'static>,
|
||||
/// The epp user who should acknowledge the transfer request
|
||||
#[serde(rename = "domain:acID", alias = "acID")]
|
||||
pub ack_id: StringValue,
|
||||
pub ack_id: StringValue<'static>,
|
||||
/// The date by which the transfer request should be acknowledged
|
||||
#[serde(rename = "domain:acDate", alias = "acDate")]
|
||||
pub ack_by: StringValue,
|
||||
pub ack_by: StringValue<'static>,
|
||||
/// The domain expiry date
|
||||
#[serde(rename = "domain:exDate", alias = "exDate")]
|
||||
pub expiring_at: Option<StringValue>,
|
||||
pub expiring_at: Option<StringValue<'static>>,
|
||||
}
|
||||
|
||||
/// Type that represents the <resData> tag for message poll response
|
||||
|
|
|
@ -60,7 +60,7 @@ pub struct CommandWrapper<'a, D, E> {
|
|||
pub data: &'a D,
|
||||
/// The client TRID
|
||||
pub extension: Option<&'a E>,
|
||||
pub client_tr_id: StringValue,
|
||||
pub client_tr_id: StringValue<'a>,
|
||||
}
|
||||
|
||||
impl<'a, D: Serialize, E: Serialize> Serialize for CommandWrapper<'a, D, E> {
|
||||
|
|
|
@ -26,7 +26,7 @@ pub struct ExtValue {
|
|||
/// Data under the <value> tag
|
||||
pub value: ResultValue,
|
||||
/// Data under the <reason> tag
|
||||
pub reason: StringValue,
|
||||
pub reason: StringValue<'static>,
|
||||
}
|
||||
|
||||
/// Type corresponding to the <result> tag in an EPP response XML
|
||||
|
@ -36,7 +36,7 @@ pub struct EppResult {
|
|||
pub code: u16,
|
||||
/// The result message
|
||||
#[serde(rename = "msg")]
|
||||
pub message: StringValue,
|
||||
pub message: StringValue<'static>,
|
||||
/// Data under the <extValue> tag
|
||||
#[serde(rename = "extValue")]
|
||||
pub ext_value: Option<ExtValue>,
|
||||
|
@ -47,10 +47,10 @@ pub struct EppResult {
|
|||
pub struct ResponseTRID {
|
||||
/// The client TRID
|
||||
#[serde(rename = "clTRID")]
|
||||
pub client_tr_id: Option<StringValue>,
|
||||
pub client_tr_id: Option<StringValue<'static>>,
|
||||
/// The server TRID
|
||||
#[serde(rename = "svTRID")]
|
||||
pub server_tr_id: StringValue,
|
||||
pub server_tr_id: StringValue<'static>,
|
||||
}
|
||||
|
||||
/// Type corresponding to the <msgQ> tag in an EPP response XML
|
||||
|
@ -62,10 +62,10 @@ pub struct MessageQueue {
|
|||
pub id: String,
|
||||
/// The message date
|
||||
#[serde(rename = "qDate")]
|
||||
pub date: Option<StringValue>,
|
||||
pub date: Option<StringValue<'static>>,
|
||||
/// The message text
|
||||
#[serde(rename = "msg")]
|
||||
pub message: Option<StringValue>,
|
||||
pub message: Option<StringValue<'static>>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
|
|
Loading…
Reference in New Issue