From a5f57fa8361de9bfa263dd5c9090d11c2a19388e Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Tue, 14 Dec 2021 09:52:08 +0100 Subject: [PATCH] Use &'static str for namespace URLs in serialize types --- src/contact/check.rs | 4 ++-- src/contact/create.rs | 4 ++-- src/contact/delete.rs | 4 ++-- src/contact/info.rs | 4 ++-- src/contact/update.rs | 4 ++-- src/domain/check.rs | 4 ++-- src/domain/create.rs | 4 ++-- src/domain/delete.rs | 4 ++-- src/domain/info.rs | 4 ++-- src/domain/renew.rs | 4 ++-- src/domain/transfer.rs | 12 ++++++------ src/domain/update.rs | 4 ++-- src/extensions/consolidate.rs | 4 ++-- src/extensions/rgp/report.rs | 4 ++-- src/extensions/rgp/request.rs | 4 ++-- src/host/check.rs | 4 ++-- src/host/create.rs | 4 ++-- src/host/delete.rs | 4 ++-- src/host/info.rs | 4 ++-- src/host/update.rs | 4 ++-- 20 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/contact/check.rs b/src/contact/check.rs index d0fa160..f5bb7af 100644 --- a/src/contact/check.rs +++ b/src/contact/check.rs @@ -15,7 +15,7 @@ impl Transaction for ContactCheck {} pub struct ContactList { /// The XML namespace for the contact <check> #[serde(rename = "xmlns:contact")] - xmlns: String, + xmlns: &'static str, /// The list of contact ids to check for availability #[serde(rename = "contact:id")] pub contact_ids: Vec, @@ -38,7 +38,7 @@ impl ContactCheck { Self { list: ContactList { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, contact_ids, }, } diff --git a/src/contact/create.rs b/src/contact/create.rs index 48aab7b..b170ac1 100644 --- a/src/contact/create.rs +++ b/src/contact/create.rs @@ -19,7 +19,7 @@ impl Command for ContactCreate { pub struct Contact { /// XML namespace for contact commands #[serde(rename = "xmlns:contact")] - xmlns: String, + xmlns: &'static str, /// Contact <id> tag #[serde(rename = "contact:id")] id: StringValue, @@ -58,7 +58,7 @@ impl ContactCreate { ) -> Self { Self { contact: Contact { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, id: id.into(), postal_info, voice, diff --git a/src/contact/delete.rs b/src/contact/delete.rs index b8eef97..527979b 100644 --- a/src/contact/delete.rs +++ b/src/contact/delete.rs @@ -17,7 +17,7 @@ impl Command for ContactDelete { pub struct ContactDeleteRequestData { /// XML namespace for the <delete> command for contacts #[serde(rename = "xmlns:contact")] - xmlns: String, + xmlns: &'static str, /// The id of the contact to be deleted #[serde(rename = "contact:id")] id: StringValue, @@ -35,7 +35,7 @@ impl ContactDelete { pub fn new(id: &str) -> ContactDelete { Self { contact: ContactDeleteRequestData { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, id: id.into(), }, } diff --git a/src/contact/info.rs b/src/contact/info.rs index acecd8b..c9a1961 100644 --- a/src/contact/info.rs +++ b/src/contact/info.rs @@ -19,7 +19,7 @@ impl Command for ContactInfo { pub struct ContactInfoRequestData { /// XML namespace for contact commands #[serde(rename = "xmlns:contact")] - xmlns: String, + xmlns: &'static str, /// The contact id for the info command #[serde(rename = "contact:id")] id: StringValue, @@ -40,7 +40,7 @@ impl ContactInfo { pub fn new(id: &str, auth_password: &str) -> ContactInfo { Self { info: ContactInfoRequestData { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, id: id.into(), auth_info: ContactAuthInfo::new(auth_password), }, diff --git a/src/contact/update.rs b/src/contact/update.rs index 9edeac7..cfa3f1a 100644 --- a/src/contact/update.rs +++ b/src/contact/update.rs @@ -16,7 +16,7 @@ impl ContactUpdate { pub fn new(id: &str) -> ContactUpdate { Self { contact: ContactUpdateRequestData { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, id: id.into(), add_statuses: None, remove_statuses: None, @@ -86,7 +86,7 @@ pub struct StatusList { #[derive(Serialize, Debug)] pub struct ContactUpdateRequestData { #[serde(rename = "xmlns:contact")] - xmlns: String, + xmlns: &'static str, #[serde(rename = "contact:id")] id: StringValue, #[serde(rename = "contact:add")] diff --git a/src/domain/check.rs b/src/domain/check.rs index 42a51d6..a2809f7 100644 --- a/src/domain/check.rs +++ b/src/domain/check.rs @@ -16,7 +16,7 @@ impl DomainCheck { pub fn new(domains: Vec<&str>) -> Self { Self { list: DomainList { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, domains: domains .into_iter() .map(|d| d.into()) @@ -33,7 +33,7 @@ impl DomainCheck { pub struct DomainList { #[serde(rename = "xmlns:domain")] /// XML namespace for domain commands - pub xmlns: String, + pub xmlns: &'static str, #[serde(rename = "domain:name")] /// List of domains to be checked for availability pub domains: Vec, diff --git a/src/domain/create.rs b/src/domain/create.rs index 2544472..f37a7bd 100644 --- a/src/domain/create.rs +++ b/src/domain/create.rs @@ -20,7 +20,7 @@ impl Command for DomainCreate { pub struct DomainCreateRequestData { /// XML namespace for domain commands #[serde(rename = "xmlns:domain")] - pub xmlns: String, + pub xmlns: &'static str, /// The domain name #[serde(rename = "domain:name")] pub name: StringValue, @@ -63,7 +63,7 @@ impl DomainCreate { ) -> Self { Self { domain: DomainCreateRequestData { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, name: name.into(), period: Period::new(period), ns, diff --git a/src/domain/delete.rs b/src/domain/delete.rs index 95b255f..85d3edd 100644 --- a/src/domain/delete.rs +++ b/src/domain/delete.rs @@ -16,7 +16,7 @@ impl DomainDelete { pub fn new(name: &str) -> Self { Self { domain: DomainDeleteRequestData { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, name: name.into(), }, } @@ -28,7 +28,7 @@ impl DomainDelete { pub struct DomainDeleteRequestData { /// XML namespace for domain commands #[serde(rename = "xmlns:domain")] - xmlns: String, + xmlns: &'static str, /// The domain to be deleted #[serde(rename = "domain:name")] name: StringValue, diff --git a/src/domain/info.rs b/src/domain/info.rs index 1235100..365c7f6 100644 --- a/src/domain/info.rs +++ b/src/domain/info.rs @@ -16,7 +16,7 @@ impl DomainInfo { pub fn new(name: &str, auth_password: Option<&str>) -> Self { Self { info: DomainInfoRequestData { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, domain: Domain { hosts: "all".to_string(), name: name.to_string(), @@ -46,7 +46,7 @@ pub struct Domain { pub struct DomainInfoRequestData { /// XML namespace for domain commands #[serde(rename = "xmlns:domain")] - xmlns: String, + xmlns: &'static str, /// The data for the domain to be queried #[serde(rename = "domain:name")] domain: Domain, diff --git a/src/domain/renew.rs b/src/domain/renew.rs index ee776c4..9e92ceb 100644 --- a/src/domain/renew.rs +++ b/src/domain/renew.rs @@ -18,7 +18,7 @@ impl DomainRenew { let exp_date_str = current_expiry_date.format("%Y-%m-%d").to_string().into(); Self { domain: DomainRenewRequestData { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, name: name.into(), current_expiry_date: exp_date_str, period: Period::new(years), @@ -34,7 +34,7 @@ impl DomainRenew { pub struct DomainRenewRequestData { /// XML namespace for domain commands #[serde(rename = "xmlns:domain")] - xmlns: String, + xmlns: &'static str, /// The name of the domain to be renewed #[serde(rename = "domain:name")] name: StringValue, diff --git a/src/domain/transfer.rs b/src/domain/transfer.rs index acec24f..98ffcd1 100644 --- a/src/domain/transfer.rs +++ b/src/domain/transfer.rs @@ -17,7 +17,7 @@ impl DomainTransfer { Self { operation: "request".to_string(), domain: DomainTransferReqData { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, name: name.into(), period: years.map(Period::new), auth_info: Some(DomainAuthInfo::new(auth_password)), @@ -29,7 +29,7 @@ impl DomainTransfer { Self { operation: "query".to_string(), domain: DomainTransferReqData { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, name: name.into(), period: None, auth_info: Some(DomainAuthInfo::new(auth_password)), @@ -41,7 +41,7 @@ impl DomainTransfer { Self { operation: "approve".to_string(), domain: DomainTransferReqData { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, name: name.into(), period: None, auth_info: None, @@ -53,7 +53,7 @@ impl DomainTransfer { Self { operation: "reject".to_string(), domain: DomainTransferReqData { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, name: name.into(), period: None, auth_info: None, @@ -65,7 +65,7 @@ impl DomainTransfer { Self { operation: "cancel".to_string(), domain: DomainTransferReqData { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, name: name.into(), period: None, auth_info: None, @@ -81,7 +81,7 @@ impl DomainTransfer { pub struct DomainTransferReqData { /// XML namespace for domain commands #[serde(rename = "xmlns:domain")] - xmlns: String, + xmlns: &'static str, /// The name of the domain under transfer #[serde(rename = "domain:name")] name: StringValue, diff --git a/src/domain/update.rs b/src/domain/update.rs index c4e3fa3..cd66d3d 100644 --- a/src/domain/update.rs +++ b/src/domain/update.rs @@ -19,7 +19,7 @@ impl DomainUpdate { pub fn new(name: &str) -> Self { Self { domain: DomainUpdateRequestData { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, name: name.into(), add: None, remove: None, @@ -75,7 +75,7 @@ pub struct DomainAddRemove { pub struct DomainUpdateRequestData { /// XML namespace for domain commands #[serde(rename = "xmlns:domain")] - pub xmlns: String, + pub xmlns: &'static str, /// The name of the domain to update #[serde(rename = "domain:name")] pub name: StringValue, diff --git a/src/extensions/consolidate.rs b/src/extensions/consolidate.rs index f6274d9..ac5d493 100644 --- a/src/extensions/consolidate.rs +++ b/src/extensions/consolidate.rs @@ -63,7 +63,7 @@ impl Update { pub fn new(expiration: GMonthDay) -> Self { Self { data: UpdateData { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, exp: expiration.to_string().into(), }, } @@ -81,7 +81,7 @@ pub struct Update { pub struct UpdateData { /// XML namespace for the consolidate extension #[serde(rename = "xmlns:sync")] - pub xmlns: String, + pub xmlns: &'static str, /// The expiry date of the domain #[serde(rename = "sync:expMonthDay")] pub exp: StringValue, diff --git a/src/extensions/rgp/report.rs b/src/extensions/rgp/report.rs index 766c667..3131f80 100644 --- a/src/extensions/rgp/report.rs +++ b/src/extensions/rgp/report.rs @@ -24,7 +24,7 @@ impl RgpRestoreReport { let statements = statements.iter().map(|&s| s.into()).collect(); RgpRestoreReport { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, restore: RgpRestoreReportSection { op: "report".to_string(), report: RgpRestoreReportSectionData { @@ -90,7 +90,7 @@ pub struct RgpRestoreReportSection { pub struct RgpRestoreReport { /// XML namespace for the RGP restore extension #[serde(rename = "xmlns:rgp")] - xmlns: String, + xmlns: &'static str, /// The object holding the list of domains to be checked #[serde(rename = "rgp:restore")] restore: RgpRestoreReportSection, diff --git a/src/extensions/rgp/request.rs b/src/extensions/rgp/request.rs index 49fb85b..e842f9a 100644 --- a/src/extensions/rgp/request.rs +++ b/src/extensions/rgp/request.rs @@ -31,7 +31,7 @@ pub struct RgpRestoreRequestData { pub struct RgpRestoreRequest { /// XML namespace for the RGP restore extension #[serde(rename = "xmlns:rgp")] - xmlns: String, + xmlns: &'static str, /// The object holding the list of domains to be checked #[serde(rename = "rgp:restore")] restore: RgpRestoreRequestData, @@ -40,7 +40,7 @@ pub struct RgpRestoreRequest { impl Default for RgpRestoreRequest { fn default() -> Self { Self { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, restore: RgpRestoreRequestData { op: "request".to_string(), }, diff --git a/src/host/check.rs b/src/host/check.rs index 53a0fb7..3f23f7e 100644 --- a/src/host/check.rs +++ b/src/host/check.rs @@ -20,7 +20,7 @@ impl HostCheck { Self { list: HostList { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, hosts, }, } @@ -34,7 +34,7 @@ impl HostCheck { pub struct HostList { /// XML namespace for host commands #[serde(rename = "xmlns:host")] - xmlns: String, + xmlns: &'static str, /// List of hosts to be checked for availability #[serde(rename = "host:name")] pub hosts: Vec, diff --git a/src/host/create.rs b/src/host/create.rs index be3caf5..a03c475 100644 --- a/src/host/create.rs +++ b/src/host/create.rs @@ -16,7 +16,7 @@ impl HostCreate { pub fn new(host: &str, addresses: Vec) -> Self { Self { host: HostCreateRequestData { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, name: host.into(), addresses: Some(addresses), }, @@ -31,7 +31,7 @@ impl HostCreate { pub struct HostCreateRequestData { /// XML namespace for host commands #[serde(rename = "xmlns:host")] - xmlns: String, + xmlns: &'static str, /// The name of the host to be created #[serde(rename = "host:name")] pub name: StringValue, diff --git a/src/host/delete.rs b/src/host/delete.rs index d5bdba5..c90a2c0 100644 --- a/src/host/delete.rs +++ b/src/host/delete.rs @@ -16,7 +16,7 @@ impl HostDelete { pub fn new(name: &str) -> Self { Self { host: HostDeleteRequestData { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, name: name.into(), }, } @@ -28,7 +28,7 @@ impl HostDelete { pub struct HostDeleteRequestData { /// XML namespace for host commands #[serde(rename = "xmlns:host")] - xmlns: String, + xmlns: &'static str, /// The host to be deleted #[serde(rename = "host:name")] name: StringValue, diff --git a/src/host/info.rs b/src/host/info.rs index dd2b3bd..13b1035 100644 --- a/src/host/info.rs +++ b/src/host/info.rs @@ -16,7 +16,7 @@ impl HostInfo { pub fn new(name: &str) -> Self { Self { info: HostInfoRequestData { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, name: name.into(), }, } @@ -30,7 +30,7 @@ impl HostInfo { pub struct HostInfoRequestData { /// XML namespace for host commands #[serde(rename = "xmlns:host")] - xmlns: String, + xmlns: &'static str, /// The name of the host to be queried #[serde(rename = "host:name")] name: StringValue, diff --git a/src/host/update.rs b/src/host/update.rs index d791827..2b35615 100644 --- a/src/host/update.rs +++ b/src/host/update.rs @@ -16,7 +16,7 @@ impl HostUpdate { pub fn new(name: &str) -> Self { Self { host: HostUpdateRequestData { - xmlns: XMLNS.to_string(), + xmlns: XMLNS, name: name.into(), add: None, remove: None, @@ -65,7 +65,7 @@ pub struct HostAddRemove { pub struct HostUpdateRequestData { /// XML namespace for host commands #[serde(rename = "xmlns:host")] - xmlns: String, + xmlns: &'static str, /// The name of the host #[serde(rename = "host:name")] name: StringValue,