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

WIP - support metadata (depth 1) #127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions cloudflare/src/endpoints/workerskv/write_bulk.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::collections::HashMap;

use crate::framework::endpoint::{Endpoint, Method};

/// Write Key-Value Pairs in Bulk
Expand Down Expand Up @@ -34,4 +36,6 @@ pub struct KeyValuePair {
pub expiration: Option<i64>,
pub expiration_ttl: Option<i64>,
pub base64: Option<bool>,
// a temporary hack for basic metadata
pub metadata: Option<HashMap<String, String>>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a meaningful distinction here between a hashmap with no values, and not having a hashmap?

If not, I think

#[serde(default)]
pub metadata: HashMap<String, String>,

makes more sense, because otherwise you're doing two checks (is option.IsSome, then hashmap.IsEmpty) but this way you eliminate the optional check, and you can safely, idk, loop or map over the hashmap without worrying about the nil case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have played with the API a bit today and realize there is actually no limitation on the shape of the metadata at all (e.g. a numeric array is also accepted). Would it be a bad idea to set it as a HashMap in this case?

}