Skip to content
Draft
Show file tree
Hide file tree
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
6 changes: 2 additions & 4 deletions examples/examples/z_ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,14 @@ fn main() {
println!("Warming up for {warmup:?}...");
let now = Instant::now();
while now.elapsed() < warmup {
let data = data.clone();
publisher.put(data).wait().unwrap();
publisher.put(&data).wait().unwrap();

let _ = sub.recv();
}

for _ in 0..n {
let data = data.clone();
let write_time = Instant::now();
publisher.put(data).wait().unwrap();
publisher.put(&data).wait().unwrap();

let _ = sub.recv();
let ts = write_time.elapsed().as_micros();
Expand Down
5 changes: 2 additions & 3 deletions examples/examples/z_ping_shm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,13 @@ fn main() {
println!("Warming up for {warmup:?}...");
let now = Instant::now();
while now.elapsed() < warmup {
publisher.put(buf.clone()).wait().unwrap();
publisher.put(&buf).wait().unwrap();
let _ = sub.recv().unwrap();
}

for _ in 0..n {
let buf = buf.clone();
let write_time = Instant::now();
publisher.put(buf).wait().unwrap();
publisher.put(&buf).wait().unwrap();

let _ = sub.recv();
let ts = write_time.elapsed().as_micros();
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_pong.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn main() {

session
.declare_subscriber(key_expr_ping)
.callback(move |sample| publisher.put(sample.payload().clone()).wait().unwrap())
.callback(move |sample| publisher.put(sample.payload()).wait().unwrap())
.background()
.wait()
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_pub_shm_thr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async fn main() {

println!("Press CTRL-C to quit...");
loop {
publisher.put(buf.clone()).await.unwrap();
publisher.put(&buf).await.unwrap();
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_pub_thr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn main() {
let mut count: usize = 0;
let mut start = std::time::Instant::now();
loop {
publisher.put(data.clone()).wait().unwrap();
publisher.put(&data).wait().unwrap();

if args.print {
if count < args.number {
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_queryable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async fn main() {
);
// Refer to z_bytes.rs to see how to serialize different types of message
query
.reply(key_expr.clone(), payload.clone())
.reply(key_expr.clone(), &payload)
.await
.unwrap_or_else(|e| println!(">> [Queryable ] Error sending reply: {e}"));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async fn main() {
println!(">> [Queryable ] Received Query '{}'", query.selector());
for (stored_name, sample) in stored.iter() {
if query.key_expr().intersects(unsafe {keyexpr::from_str_unchecked(stored_name)}) {
query.reply(sample.key_expr().clone(), sample.payload().clone()).await.unwrap();
query.reply(sample.key_expr().clone(), sample.payload()).await.unwrap();
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions zenoh/src/api/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,12 @@
}
}

impl From<&ZBytes> for ZBytes {
fn from(value: &ZBytes) -> Self {
value.clone()
}

Check warning on line 369 in zenoh/src/api/bytes.rs

View check run for this annotation

Codecov / codecov/patch

zenoh/src/api/bytes.rs#L367-L369

Added lines #L367 - L369 were not covered by tests
}

impl From<ZBuf> for ZBytes {
fn from(value: ZBuf) -> Self {
Self(value)
Expand Down
Loading