zenoh icon indicating copy to clipboard operation
zenoh copied to clipboard

zenoh-ext serialization and deserialization for structs with serde support

Open mxgrey opened this issue 3 months ago • 0 comments

Describe the feature

There seems to be considerable overlap between the Serialize / Deserialize traits in zenoh-ext and the same traits in the serde crate. If it were possible to add a feature flag to zenoh-ext that provides an adapter so that anything with the Serialize / Deserialize traits in serde can be converted into ZBytes with the zenoh serialization protocol, it would make zenoh much more accessible for data structures in the broader Rust ecosystem.

I'm not sure if there's any fundamental incompatibility between what's needed by the serialization/deserialization of zenoh-ext versus serde. Here's one approach that comes to mind for me:

  • zenoh-ext can provide structs that implement the serde::ser::Serializer and serde::Deserializer traits. These traits would convert to/from ZBytes encoded in the zenoh protocol.
  • If there are data types supported by serde which aren't supported by the zenoh protocol, then the serializer/deserializer can return an Err
  • If there are data types supported by the zenoh protocol that aren't covered by serde, then that data just goes unused when being handled by serde

mxgrey avatar Oct 07 '25 05:10 mxgrey