Use &'static str for namespace URLs in serialize types

This commit is contained in:
Dirkjan Ochtman 2021-12-14 09:52:08 +01:00 committed by masalachai
parent b0595511e4
commit a5f57fa836
20 changed files with 44 additions and 44 deletions

View File

@ -15,7 +15,7 @@ impl Transaction<NoExtension> for ContactCheck {}
pub struct ContactList {
/// The XML namespace for the contact &lt;check&gt;
#[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<StringValue>,
@ -38,7 +38,7 @@ impl ContactCheck {
Self {
list: ContactList {
xmlns: XMLNS.to_string(),
xmlns: XMLNS,
contact_ids,
},
}

View File

@ -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 &lt;id&gt; 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,

View File

@ -17,7 +17,7 @@ impl Command for ContactDelete {
pub struct ContactDeleteRequestData {
/// XML namespace for the &lt;delete&gt; 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(),
},
}

View File

@ -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),
},

View File

@ -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")]

View File

@ -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<StringValue>,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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(),
},

View File

@ -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<StringValue>,

View File

@ -16,7 +16,7 @@ impl HostCreate {
pub fn new(host: &str, addresses: Vec<HostAddr>) -> 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,

View File

@ -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,

View File

@ -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,

View File

@ -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,