@@ -199,7 +199,7 @@ <h1 id="custom-messages"><a class="header" href="#custom-messages">Custom Messag
199199</ pre >
200200< hr />
201201< h2 id ="rust-native-messages "> < a class ="header " href ="#rust-native-messages "> Rust-Native Messages</ a > </ h2 >
202- < p > < strong > Define messages directly in Rust by implementing required traits .</ strong > This approach is fast for prototyping but only works between ros-z nodes.</ p >
202+ < p > < strong > Define messages directly in Rust and derive their schema metadata .</ strong > This approach is fast for prototyping but only works between ros-z nodes.</ p >
203203< div id ="admonition-warning " class ="admonition admonish-warning " role ="note " aria-labelledby ="admonition-warning-title ">
204204< div class ="admonition-title ">
205205< div id ="admonition-warning-title ">
@@ -213,42 +213,37 @@ <h2 id="rust-native-messages"><a class="header" href="#rust-native-messages">Rus
213213</ div >
214214< h3 id ="workflow-of-rust-native-messages "> < a class ="header " href ="#workflow-of-rust-native-messages "> Workflow of Rust-Native Messages</ a > </ h3 >
215215< pre class ="mermaid "> graph LR
216- A[Define Struct] --> B[Impl MessageTypeInfo]
216+ A[Define Struct] --> B[Derive MessageTypeInfo]
217217 B --> C[Add Serde Traits]
218- C --> D[Impl WithTypeInfo ]
218+ C --> D[Impl ZMessage ]
219219 D --> E[Use in Pub/Sub]
220220</ pre >
221221< h3 id ="required-traits "> < a class ="header " href ="#required-traits "> Required Traits</ a > </ h3 >
222222< div class ="table-wrapper "> < table > < thead > < tr > < th > Trait</ th > < th > Purpose</ th > < th > Key Method</ th > </ tr > </ thead > < tbody >
223- < tr > < td > < strong > MessageTypeInfo</ strong > </ td > < td > Type identification</ td > < td > < code > type_name()</ code > , < code > type_hash()</ code > </ td > </ tr >
224- < tr > < td > < strong > WithTypeInfo</ strong > </ td > < td > ros-z integration</ td > < td > < code > type_info()</ code > </ td > </ tr >
223+ < tr > < td > < strong > MessageTypeInfo</ strong > </ td > < td > Type identification + runtime schema</ td > < td > < code > type_name()</ code > , < code > type_hash()</ code > , < code > message_schema()</ code > </ td > </ tr >
225224< tr > < td > < strong > Serialize/Deserialize</ strong > </ td > < td > Data encoding</ td > < td > From < code > serde</ code > </ td > </ tr >
225+ < tr > < td > < strong > ZMessage</ strong > </ td > < td > ros-z serialization path</ td > < td > < code > type Serdes = SerdeCdrSerdes<Self></ code > </ td > </ tr >
226226</ tbody > </ table >
227227</ div >
228228< h3 id ="message-example "> < a class ="header " href ="#message-example "> Message Example</ a > </ h3 >
229- < pre > < code class ="language-rust ignore "> use ros_z::{MessageTypeInfo, entity::TypeHash};
230- use ros_z::ros_msg::WithTypeInfo;
229+ < pre > < code class ="language-rust ignore "> use ros_z::MessageTypeInfo;
231230use serde::{Serialize, Deserialize};
232231
233- #[derive(Debug, Clone, Serialize, Deserialize)]
232+ #[derive(Debug, Clone, Serialize, Deserialize, MessageTypeInfo)]
233+ #[ros_msg(type_name = "my_msgs/msg/RobotStatus")]
234234struct RobotStatus {
235235 battery_level: f32,
236236 position_x: f32,
237237 position_y: f32,
238238 is_moving: bool,
239239}
240240
241- impl MessageTypeInfo for RobotStatus {
242- fn type_name() -> &'static str {
243- "my_msgs::msg::dds_::RobotStatus_"
244- }
245-
246- fn type_hash() -> TypeHash {
247- TypeHash::zero() // ros-z-to-ros-z only
248- }
249- }
250-
251- impl WithTypeInfo for RobotStatus {}</ code > </ pre >
241+ impl ros_z::msg::ZMessage for RobotStatus {
242+ type Serdes = ros_z::msg::SerdeCdrSerdes<Self>;
243+ }</ code > </ pre >
244+ < p > < code > MessageTypeInfo</ code > derive currently supports named structs with deterministic ROS field mappings:
245+ primitive numeric/bool types, < code > String</ code > , < code > Vec<T></ code > , fixed arrays < code > [T; N]</ code > , and nested message structs.
246+ Tuple structs, unit structs, enums, < code > Option</ code > , maps, and other richer Rust-only shapes are not yet supported.</ p >
252247< h3 id ="service-example "> < a class ="header " href ="#service-example "> Service Example</ a > </ h3 >
253248< pre > < code class ="language-rust ignore "> use ros_z::{ServiceTypeInfo, TypeInfo, TypeHash, msg::ZService};
254249
@@ -276,6 +271,8 @@ <h3 id="service-example"><a class="header" href="#service-example">Service Examp
276271 type Response = NavigateToResponse;
277272}</ code > </ pre >
278273< p > See the < code > z_custom_message</ code > example:</ p >
274+ < p > When a publisher node enables the type description service, derived custom message types
275+ automatically register their runtime schema so dynamic subscribers can discover them.</ p >
279276< pre > < code class ="language-bash "> # Terminal 1: Router
280277cargo run --example zenoh_router
281278
0 commit comments