zenoh icon indicating copy to clipboard operation
zenoh copied to clipboard

Implement `From<&ZBytes> for ZBytes` to simplify usage

Open evshary opened this issue 6 months ago • 2 comments

Now we need to use publisher.put(sample.payload().clone()).wait().unwrap() because ZBytes can't be transformed into &ZBytes. Initially, we considered implementing the Copy trait, but Copy can't be implemented in Vec, which is used in SingleOrVec. If we implement From<&ZBytes> for ZBytes, then sample.payload() (&ZBytes) can be transformed into ZBytes implicitly, and it simplifies the usage. The downside might be that users aren't aware of the implicit clone, but it should be okay when the clone here is cheap.

evshary avatar Jun 09 '25 05:06 evshary

PR missing one of the required labels: {'new feature', 'breaking-change', 'dependencies', 'internal', 'enhancement', 'bug', 'documentation'}

github-actions[bot] avatar Jun 09 '25 05:06 github-actions[bot]

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 70.89%. Comparing base (b33ddc3) to head (d2ae4cc).

Files with missing lines Patch % Lines
zenoh/src/api/bytes.rs 0.00% 3 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1981      +/-   ##
==========================================
- Coverage   71.03%   70.89%   -0.15%     
==========================================
  Files         364      364              
  Lines       61519    61522       +3     
==========================================
- Hits        43697    43613      -84     
- Misses      17822    17909      +87     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jun 09 '25 06:06 codecov[bot]