From f1e4e024d5a8bc359b3d48b4313c4e7095e1a1ba Mon Sep 17 00:00:00 2001 From: Ivan Folgueira Bande Date: Thu, 9 Jan 2025 22:31:20 +0100 Subject: [PATCH] use of Option in StoreWakuMessageResponse for responses with or withoug msgs --- examples/toy-chat/src/main.rs | 17 ++++++++++------- waku-bindings/src/node/store.rs | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/toy-chat/src/main.rs b/examples/toy-chat/src/main.rs index 101c667..e5890fd 100644 --- a/examples/toy-chat/src/main.rs +++ b/examples/toy-chat/src/main.rs @@ -152,13 +152,16 @@ impl App { Some(time_start), None, None).await.unwrap(); - let messages:Vec<_> = messages - .iter() - .map(|store_resp_msg| { - ::decode(store_resp_msg.message.payload()) - .expect("Toy chat messages should be decodeable") - }) - .collect(); + + let messages: Vec<_> = messages + .into_iter() + // we expect messages because the query was passed with include_data == true + .filter(|item| item.message.is_some()) + .map(|store_resp_msg| { + ::decode(store_resp_msg.message.unwrap().payload()) + .expect("Toy chat messages should be decodeable") + }) + .collect(); if !messages.is_empty() { *self.messages.write().unwrap() = messages; diff --git a/waku-bindings/src/node/store.rs b/waku-bindings/src/node/store.rs index b17bc73..2225e86 100644 --- a/waku-bindings/src/node/store.rs +++ b/waku-bindings/src/node/store.rs @@ -109,7 +109,7 @@ impl StoreQueryRequest { #[serde(rename_all = "camelCase")] pub struct StoreWakuMessageResponse { pub message_hash: MessageHash, - pub message: WakuStoreRespMessage, + pub message: Option, // None if include_data == false pub pubsub_topic: String, }