Skip to content

Commit

Permalink
Fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Mallets committed Apr 26, 2024
1 parent 136beff commit f08ea12
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions examples/examples/z_sub_shm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use clap::Parser;
use zenoh::config::Config;
use zenoh::prelude::r#async::*;
use zenoh::shm::zsliceshm;
use zenoh_examples::CommonArgs;

#[tokio::main]
Expand All @@ -35,39 +36,39 @@ async fn main() {
let subscriber = session.declare_subscriber(&key_expr).res().await.unwrap();

println!("Press CTRL-C to quit...");
// while let Ok(sample) = subscriber.recv_async().await {
// match sample.payload().deserialize::<&zsliceshm>() {
// Ok(payload) => println!(
// ">> [Subscriber] Received {} ('{}': '{:02x?}')",
// sample.kind(),
// sample.key_expr().as_str(),
// payload
// ),
// Err(e) => {
// println!(">> [Subscriber] Not a SharedMemoryBuf: {:?}", e);
// }
// }
// }

// // Try to get a mutable reference to the SHM buffer. If this subscriber is the only subscriber
// // holding a reference to the SHM buffer, then it will be able to get a mutable reference to it.
// // With the mutable reference at hand, it's possible to mutate in place the SHM buffer content.
//
use zenoh::shm::slice::zsliceshmmut::zsliceshmmut;

while let Ok(mut sample) = subscriber.recv_async().await {
let kind = sample.kind();
let key_expr = sample.key_expr().to_string();
match sample.payload_mut().deserialize_mut::<&mut zsliceshmmut>() {
while let Ok(sample) = subscriber.recv_async().await {
match sample.payload().deserialize::<&zsliceshm>() {
Ok(payload) => println!(
">> [Subscriber] Received {} ('{}': '{:02x?}')",
kind, key_expr, payload
sample.kind(),
sample.key_expr().as_str(),
payload
),
Err(e) => {
println!(">> [Subscriber] Not a SharedMemoryBuf: {:?}", e);
}
}
}

// // Try to get a mutable reference to the SHM buffer. If this subscriber is the only subscriber
// // holding a reference to the SHM buffer, then it will be able to get a mutable reference to it.
// // With the mutable reference at hand, it's possible to mutate in place the SHM buffer content.
//
// use zenoh::shm::zsliceshmmut;

// while let Ok(mut sample) = subscriber.recv_async().await {
// let kind = sample.kind();
// let key_expr = sample.key_expr().to_string();
// match sample.payload_mut().deserialize_mut::<&mut zsliceshmmut>() {
// Ok(payload) => println!(
// ">> [Subscriber] Received {} ('{}': '{:02x?}')",
// kind, key_expr, payload
// ),
// Err(e) => {
// println!(">> [Subscriber] Not a SharedMemoryBuf: {:?}", e);
// }
// }
// }
}

#[derive(clap::Parser, Clone, PartialEq, Eq, Hash, Debug)]
Expand Down

0 comments on commit f08ea12

Please sign in to comment.