Skip to content

Commit

Permalink
Read optional params from json blob instead
Browse files Browse the repository at this point in the history
  • Loading branch information
gabbifish committed Aug 18, 2019
1 parent 8270bec commit 9202ed5
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/workerskv/write_bulk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ use crate::endpoint::{Endpoint, Method};
pub struct BulkWrite<'a> {
pub account_identifier: &'a str,
pub namespace_identifier: &'a str,
pub params: BulkWriteParams<'a>,
pub bulk_key_value_pairs: Vec<KeyValuePair>,
}

impl<'a> Endpoint<(), BulkWriteParams<'a>, Vec<KeyValuePair>> for BulkWrite<'a> {
impl<'a> Endpoint<(), (), Vec<KeyValuePair>> for BulkWrite<'a> {
fn method(&self) -> Method {
Method::Put
}
Expand All @@ -22,23 +21,17 @@ impl<'a> Endpoint<(), BulkWriteParams<'a>, Vec<KeyValuePair>> for BulkWrite<'a>
fn body(&self) -> Option<Vec<KeyValuePair>> {
Some(self.bulk_key_value_pairs.clone())
}
fn query(&self) -> Option<BulkWriteParams<'a>> {
Some(self.params.clone())
}
// default content-type is already application/json
}

#[derive(Serialize, Clone, Debug)]
pub struct BulkWriteParams<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub expiration: Option<&'a str>,
#[serde(skip_serializing_if = "Option::is_none")]
pub expiration_ttl: Option<&'a str>,
}

#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct KeyValuePair {
pub key: String,
pub value: String,
pub base64: bool,
}
#[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 base64: Option<bool>,
}

0 comments on commit 9202ed5

Please sign in to comment.