We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 566af62 commit 9461501Copy full SHA for 9461501
src/message.rs
@@ -6,7 +6,8 @@ use std::collections::HashMap;
6
#[derive(Deserialize, Clone, Serialize)]
7
pub struct EncodedMessage {
8
data: String,
9
- attributes: HashMap<String, String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
10
+ attributes: Option<HashMap<String, String>>,
11
}
12
13
pub trait FromPubSubMessage
@@ -24,10 +25,7 @@ impl EncodedMessage {
24
25
pub fn new<T: serde::Serialize>(data: &T, attributes: Option<HashMap<String, String>>) -> Self {
26
let json = serde_json::to_string(data).unwrap();
27
let data = base64::encode(&json);
- EncodedMessage {
28
- data,
29
- attributes: attributes.unwrap_or_default(),
30
- }
+ EncodedMessage { data, attributes }
31
32
33
0 commit comments