Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use neater serde_with::skip_serializing_none logic #31

Merged
merged 2 commits into from
Aug 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ serde_derive = "1.0"
serde_json = "1.0"
serde_qs = "0.4"
serde_yaml = "0.8"
serde_with = "1.3.1"
slog = "2.4"
slog-term = "2.4"
sloggers = "0.3"
Expand Down
13 changes: 3 additions & 10 deletions src/endpoints/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,15 @@ impl<'a> Endpoint<DnsRecord, (), CreateDnsRecordParams<'a>> for CreateDnsRecord<
}
}

#[serde_with::skip_serializing_none]
#[derive(Serialize, Clone, Debug)]
pub struct CreateDnsRecordParams<'a> {
/// Time to live for DNS record. Value of 1 is 'automatic'
#[serde(skip_serializing_if = "Option::is_none")]
pub ttl: Option<u32>,
/// Used with some records like MX and SRV to determine priority.
/// If you do not supply a priority for an MX record, a default value of 0 will be set
#[serde(skip_serializing_if = "Option::is_none")]
pub priority: Option<u16>,
/// Whether the record is receiving the performance and security benefits of Cloudflare
#[serde(skip_serializing_if = "Option::is_none")]
pub proxied: Option<bool>,
/// DNS record name
pub name: &'a str,
Expand Down Expand Up @@ -92,21 +90,16 @@ pub enum ListDnsRecordsOrder {
Proxied,
}

#[serde_with::skip_serializing_none]
#[derive(Serialize, Clone, Debug, Default)]
pub struct ListDnsRecordsParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub record_type: Option<DnsContent>,
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub page: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub per_page: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub order: Option<ListDnsRecordsOrder>,
#[serde(skip_serializing_if = "Option::is_none")]
pub direction: Option<OrderDirection>,
#[serde(rename = "match", skip_serializing_if = "Option::is_none")]
#[serde(rename = "match")]
pub search_match: Option<SearchMatch>,
}

Expand Down
8 changes: 3 additions & 5 deletions src/endpoints/workerskv/write_bulk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ impl<'a> Endpoint<(), (), Vec<KeyValuePair>> for WriteBulk<'a> {
// default content-type is already application/json
}

#[serde_with::skip_serializing_none]
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct KeyValuePair {
pub key: String,
pub value: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub expiration: Option<i32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub expiration_ttl: Option<i32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub expiration: Option<i64>,
pub expiration_ttl: Option<i64>,
pub base64: Option<bool>,
}