Skip to content

Commit dbf787b

Browse files
authored
Allow to make get request without payload in the example (#1972)
1 parent c528884 commit dbf787b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

examples/examples/z_get.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,19 @@ async fn main() {
3131
let session = zenoh::open(config).await.unwrap();
3232

3333
println!("Sending Query '{selector}'...");
34-
let replies = session
34+
let mut builder = session
3535
.get(&selector)
3636
// // By default get receives replies from a FIFO.
3737
// // Uncomment this line to use a ring channel instead.
3838
// // More information on the ring channel are available in the z_pull example.
3939
// .with(zenoh::handlers::RingChannel::default())
4040
// Refer to z_bytes.rs to see how to serialize different types of message
41-
.payload(payload.unwrap_or_default())
4241
.target(target)
43-
.timeout(timeout)
44-
.await
45-
.unwrap();
42+
.timeout(timeout);
43+
if let Some(payload) = payload {
44+
builder = builder.payload(payload);
45+
}
46+
let replies = builder.await.unwrap();
4647
while let Ok(reply) = replies.recv_async().await {
4748
match reply.result() {
4849
Ok(sample) => {

0 commit comments

Comments
 (0)