refactor(msg): decouple serialization from ZMessage via ZSerdes<T> trait#131
Open
YuanYuYuan wants to merge 14 commits into
Open
refactor(msg): decouple serialization from ZMessage via ZSerdes<T> trait#131YuanYuYuan wants to merge 14 commits into
YuanYuYuan wants to merge 14 commits into
Conversation
Replace the ZMessage::Serdes associated type with a ZSerdes<T> type parameter on ZPub/ZSub/ZClient/ZServer builders. This allows external message ecosystems (roslibrust) to use ros-z pub/sub directly without wrapper types, and enables future formats (FlatBuffers, Protobuf) at the call site rather than baked into the message type. - ZMessage becomes a plain Send+Sync+'static marker (no associated type) - NativeCdrSerdes/SerdeCdrSerdes become unit structs implementing ZSerdes<T> - ZPub/ZSub default to NativeCdrSerdes; builders expose .with_serdes::<S>() - All action, dynamic, and service call sites updated to explicit ZSerdes API - roslibrust_ros2: drops RosMessageWrapper and WrapperSerdes, uses SerdeCdrSerdes directly via create_pub_impl/create_sub_impl
After introducing the ZMessage blanket impl, all manual
'impl ZMessage for T {}' in examples, tests, and codegen templates
became orphan conflicts. Remove them.
Also add .with_serdes::<SerdeCdrSerdes>() at serde-only pub/sub call
sites (z_custom_message example, pubsub tests) where NativeCdrSerdes
cannot satisfy the ZSerdes<T> bound.
Remove misleading 'implement ZMessage' language from actions.md and protobuf_demo — users no longer write impl ZMessage, it's automatic.
|
- protobuf_demo: ProtobufSerdes is now a unit struct, remove type param - rmw-zenoh-rs/msg.rs: disambiguate Self::serialize with fully-qualified syntax - service.rs: make rmw_send_request generic over S: ZSerdes, add rmw_send_response for RMW path that bypasses serde bounds
…moving ZSerdes bound overlap
ros-z-py is not in default-members so cargo clippy/build silently skip it. Adding cargo check/clippy -p ros-z-py catches missing deps and type errors locally before they reach CI.
CdrSerdes implements ZSerdes<T> but not ZSerializer/ZDeserializer directly. The publish_serialized and recv_serialized paths don't need those bounds, so drop them from ZPubWrapper and ZSubWrapper struct/impl definitions. Also add explicit type annotation on zenoh::Error to fix E0282.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Decouples serialization format from message type by replacing
ZMessage::Serdes(an associated type) with aZSerdes<T>trait parameter on publishers, subscribers, and service builders. This enables any message ecosystem — including roslibrust — to plug in a custom wire format without wrapper boilerplate.Key Changes
ZMessageis now a plain marker trait with a blanket impl covering allSend + Sync + 'statictypes; no manualimpl ZMessageneededZSerdes<T>trait replaces the old associated type — unit structsNativeCdrSerdesandSerdeCdrSerdesimplement it for their respective boundsZPub<T, S = NativeCdrSerdes>/ZSub<T, Q, S = NativeCdrSerdes>— newStype parameter with default preserves all existing generated-message callers unchanged.with_serdes::<S>()method on all builders for overriding the wire format at the call siteZNode::create_pub_impl/create_sub_impl—#[doc(hidden)]methods accepting explicitOption<TypeInfo>enable external ecosystems to bypass theWithTypeInforequirementRosMessageWrapperandWrapperSerdesdropped;T: RosMessageTypeis now used directly withSerdeCdrSerdesvia.with_serdes()ZSerdessyntaxBreaking Changes
Types that previously called
impl ZMessage for MyType { type Serdes = ...; }must be updated:impl ZMessageblock entirely — it is now a blanket impl.publish()/.recv()callers that relied ontype Serdeswith an explicit.with_serdes::<S>()on the builder if the type is notCdrSerialize + CdrDeserialize + CdrSerializedSize(i.e., serde-only types need.with_serdes::<SerdeCdrSerdes>())