Skip to content

Commit 2bd99dd

Browse files
committed
refactor(msg): rename NativeCdrSerdes->CdrSerdes, SerdeCdrSerdes->CdrCompatSerdes
1 parent 9f09094 commit 2bd99dd

File tree

23 files changed

+231
-234
lines changed

23 files changed

+231
-234
lines changed

crates/ros-z-codegen/src/python_msgspec_generator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ fn generate_serialize_to_zbuf(
644644
match_arms.push(quote! {
645645
#full_name => {
646646
let rust_msg = <ros::#package_ident::#name_ident>::from_py(msg)?;
647-
Ok(::ros_z::msg::NativeCdrSerdes::serialize(&rust_msg))
647+
Ok(::ros_z::msg::CdrSerdes::serialize(&rust_msg))
648648
}
649649
});
650650
}
@@ -660,7 +660,7 @@ fn generate_serialize_to_zbuf(
660660
match_arms.push(quote! {
661661
#req_full_name => {
662662
let rust_msg = <ros::#package_ident::#req_name_ident>::from_py(msg)?;
663-
Ok(::ros_z::msg::NativeCdrSerdes::serialize(&rust_msg))
663+
Ok(::ros_z::msg::CdrSerdes::serialize(&rust_msg))
664664
}
665665
});
666666

@@ -670,7 +670,7 @@ fn generate_serialize_to_zbuf(
670670
match_arms.push(quote! {
671671
#resp_full_name => {
672672
let rust_msg = <ros::#package_ident::#resp_name_ident>::from_py(msg)?;
673-
Ok(::ros_z::msg::NativeCdrSerdes::serialize(&rust_msg))
673+
Ok(::ros_z::msg::CdrSerdes::serialize(&rust_msg))
674674
}
675675
});
676676
}

crates/ros-z-console/src/core/dynamic_subscriber.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{sync::Arc, time::Duration};
77

88
use flume::Receiver;
99
use ros_z::{
10-
dynamic::{DynamicMessage, DynamicSerdeCdrSerdes, MessageSchema},
10+
dynamic::{DynamicCdrCompatSerdes, DynamicMessage, MessageSchema},
1111
node::ZNode,
1212
pubsub::ZSub,
1313
};
@@ -25,7 +25,7 @@ pub struct DynamicTopicSubscriber {
2525
/// Channel for receiving messages asynchronously
2626
message_rx: Receiver<DynamicMessage>,
2727
/// Subscriber handle (kept alive to maintain subscription)
28-
_subscriber: Arc<ZSub<DynamicMessage, Sample, DynamicSerdeCdrSerdes>>,
28+
_subscriber: Arc<ZSub<DynamicMessage, Sample, DynamicCdrCompatSerdes>>,
2929
}
3030

3131
impl DynamicTopicSubscriber {

crates/ros-z-msgs/tests/shm_size_estimation.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::sync::Arc;
99

1010
use ros_z::{
1111
ZBuf,
12-
msg::{NativeCdrSerdes, ZMessage, ZSerdes},
12+
msg::{CdrSerdes, ZMessage, ZSerdes},
1313
shm::ShmProviderBuilder,
1414
};
1515
use zenoh_buffers::buffer::Buffer;
@@ -83,7 +83,7 @@ fn test_pointcloud2_shm_serialization_with_accurate_estimate() {
8383

8484
// Serialize to SHM - should not panic!
8585
let result =
86-
<NativeCdrSerdes as ZSerdes<PointCloud2>>::serialize_to_shm(&cloud, estimated, &provider);
86+
<CdrSerdes as ZSerdes<PointCloud2>>::serialize_to_shm(&cloud, estimated, &provider);
8787

8888
assert!(result.is_ok(), "SHM serialization should succeed");
8989

@@ -149,8 +149,7 @@ fn test_image_shm_serialization_with_accurate_estimate() {
149149
.expect("Failed to create SHM provider"),
150150
);
151151

152-
let result =
153-
<NativeCdrSerdes as ZSerdes<Image>>::serialize_to_shm(&image, estimated, &provider);
152+
let result = <CdrSerdes as ZSerdes<Image>>::serialize_to_shm(&image, estimated, &provider);
154153
assert!(result.is_ok(), "SHM serialization should succeed");
155154

156155
let (zbuf, actual_size) = result.unwrap();
@@ -207,8 +206,7 @@ fn test_laserscan_shm_serialization_with_accurate_estimate() {
207206
.expect("Failed to create SHM provider"),
208207
);
209208

210-
let result =
211-
<NativeCdrSerdes as ZSerdes<LaserScan>>::serialize_to_shm(&scan, estimated, &provider);
209+
let result = <CdrSerdes as ZSerdes<LaserScan>>::serialize_to_shm(&scan, estimated, &provider);
212210
assert!(result.is_ok(), "SHM serialization should succeed");
213211

214212
let (zbuf, actual_size) = result.unwrap();
@@ -259,7 +257,7 @@ fn test_compressed_image_shm_serialization() {
259257
);
260258

261259
let result =
262-
<NativeCdrSerdes as ZSerdes<CompressedImage>>::serialize_to_shm(&img, estimated, &provider);
260+
<CdrSerdes as ZSerdes<CompressedImage>>::serialize_to_shm(&img, estimated, &provider);
263261
assert!(result.is_ok(), "SHM serialization should succeed");
264262

265263
let (zbuf, actual_size) = result.unwrap();
@@ -301,8 +299,7 @@ fn test_multiple_messages_share_shm_pool() {
301299
};
302300

303301
let estimated = image.estimated_serialized_size();
304-
let result =
305-
<NativeCdrSerdes as ZSerdes<Image>>::serialize_to_shm(&image, estimated, &provider);
302+
let result = <CdrSerdes as ZSerdes<Image>>::serialize_to_shm(&image, estimated, &provider);
306303

307304
assert!(
308305
result.is_ok(),

crates/ros-z-msgs/tests/size_estimation_performance.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::time::Instant;
77

88
use ros_z::{
99
ZBuf,
10-
msg::{NativeCdrSerdes, ZMessage, ZSerdes},
10+
msg::{CdrSerdes, ZMessage, ZSerdes},
1111
};
1212
use ros_z_msgs::{builtin_interfaces::Time, sensor_msgs::*, std_msgs::Header};
1313
use zenoh_buffers::buffer::Buffer;
@@ -33,13 +33,13 @@ fn test_pointcloud2_serialization_performance() {
3333

3434
// Warm up
3535
for _ in 0..5 {
36-
let _ = NativeCdrSerdes::serialize(&cloud);
36+
let _ = CdrSerdes::serialize(&cloud);
3737
}
3838

3939
// Benchmark with accurate size estimation (current implementation)
4040
let start = Instant::now();
4141
for _ in 0..100 {
42-
let zbuf = NativeCdrSerdes::serialize(&cloud);
42+
let zbuf = CdrSerdes::serialize(&cloud);
4343
assert!(zbuf.len() > 1_000_000);
4444
}
4545
let with_estimation = start.elapsed();
@@ -71,13 +71,13 @@ fn test_image_serialization_performance() {
7171

7272
// Warm up
7373
for _ in 0..5 {
74-
let _ = NativeCdrSerdes::serialize(&image);
74+
let _ = CdrSerdes::serialize(&image);
7575
}
7676

7777
// Benchmark
7878
let start = Instant::now();
7979
for _ in 0..100 {
80-
let zbuf = NativeCdrSerdes::serialize(&image);
80+
let zbuf = CdrSerdes::serialize(&image);
8181
assert!(zbuf.len() > 920_000);
8282
}
8383
let elapsed = start.elapsed();
@@ -108,7 +108,7 @@ fn test_estimated_size_matches_actual() {
108108
};
109109

110110
let estimated = cloud.estimated_serialized_size();
111-
let zbuf = NativeCdrSerdes::serialize(&cloud);
111+
let zbuf = CdrSerdes::serialize(&cloud);
112112
let actual = zbuf.len();
113113

114114
println!("PointCloud2: estimated={}, actual={}", estimated, actual);
@@ -133,7 +133,7 @@ fn test_estimated_size_matches_actual() {
133133
};
134134

135135
let estimated = image.estimated_serialized_size();
136-
let zbuf = NativeCdrSerdes::serialize(&image);
136+
let zbuf = CdrSerdes::serialize(&image);
137137
let actual = zbuf.len();
138138

139139
println!("Image: estimated={}, actual={}", estimated, actual);
@@ -161,7 +161,7 @@ fn test_estimated_size_matches_actual() {
161161
};
162162

163163
let estimated = scan.estimated_serialized_size();
164-
let zbuf = NativeCdrSerdes::serialize(&scan);
164+
let zbuf = CdrSerdes::serialize(&scan);
165165
let actual = zbuf.len();
166166

167167
println!("LaserScan: estimated={}, actual={}", estimated, actual);
@@ -191,12 +191,12 @@ fn test_capacity_hint_api() {
191191

192192
// Test serialize_with_hint (capacity hint API)
193193
let hint = cloud.estimated_serialized_size();
194-
let zbuf = <NativeCdrSerdes as ZSerdes<PointCloud2>>::serialize_with_hint(&cloud, hint);
194+
let zbuf = <CdrSerdes as ZSerdes<PointCloud2>>::serialize_with_hint(&cloud, hint);
195195

196196
assert!(zbuf.len() > 50_000);
197197
println!("Serialized with explicit hint: {} bytes", zbuf.len());
198198

199199
// Both serialize paths should produce the same length
200-
let zbuf2 = NativeCdrSerdes::serialize(&cloud);
200+
let zbuf2 = CdrSerdes::serialize(&cloud);
201201
assert_eq!(zbuf.len(), zbuf2.len());
202202
}

crates/ros-z-py/src/service.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use anyhow::Result;
22
use pyo3::prelude::*;
33
use pyo3::types::PyDict;
4-
use ros_z::msg::{SerdeCdrSerdes, ZMessage, ZSerdes, ZService};
4+
use ros_z::msg::{CdrCompatSerdes, ZMessage, ZSerdes, ZService};
55
use ros_z::service::{QueryKey, ZClient, ZServer};
66
use std::time::Duration;
77

@@ -31,7 +31,7 @@ where
3131
{
3232
fn send_request_serialized(&self, data: &[u8]) -> Result<()> {
3333
// Deserialize the request from CDR bytes
34-
let request = <SerdeCdrSerdes as ZSerdes<T::Request>>::deserialize(data)
34+
let request = <CdrCompatSerdes as ZSerdes<T::Request>>::deserialize(data)
3535
.map_err(|e| anyhow::anyhow!("Failed to deserialize request: {:?}", e))?;
3636

3737
// Send the request (this is async in Rust, but we'll block here for Python)
@@ -57,7 +57,7 @@ where
5757
.map_err(|e| anyhow::anyhow!("Failed to receive response: {}", e))?;
5858

5959
// Serialize the response to CDR bytes
60-
Ok(<SerdeCdrSerdes as ZSerdes<T::Response>>::serialize_to_vec(
60+
Ok(<CdrCompatSerdes as ZSerdes<T::Response>>::serialize_to_vec(
6161
&response,
6262
))
6363
}
@@ -66,7 +66,7 @@ where
6666
// Use a minimal timeout for non-blocking behavior
6767
match self.inner.take_response_timeout(Duration::from_millis(1)) {
6868
Ok(response) => Ok(Some(
69-
<SerdeCdrSerdes as ZSerdes<T::Response>>::serialize_to_vec(&response),
69+
<CdrCompatSerdes as ZSerdes<T::Response>>::serialize_to_vec(&response),
7070
)),
7171
Err(e) => {
7272
let err_str = e.to_string();
@@ -122,13 +122,13 @@ where
122122
// Serialize the request to CDR bytes
123123
Ok((
124124
key,
125-
<SerdeCdrSerdes as ZSerdes<T::Request>>::serialize_to_vec(&request),
125+
<CdrCompatSerdes as ZSerdes<T::Request>>::serialize_to_vec(&request),
126126
))
127127
}
128128

129129
fn send_response_serialized(&self, data: &[u8], key: &QueryKey) -> Result<()> {
130130
// Deserialize the response from CDR bytes
131-
let response = <SerdeCdrSerdes as ZSerdes<T::Response>>::deserialize(data)
131+
let response = <CdrCompatSerdes as ZSerdes<T::Response>>::deserialize(data)
132132
.map_err(|e| anyhow::anyhow!("Failed to deserialize response: {:?}", e))?;
133133

134134
let mut server = self

crates/ros-z-tests/tests/type_description_interop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use common::*;
2424
use ros_z::{
2525
Builder,
2626
dynamic::{
27-
DynamicMessage, DynamicSerdeCdrSerdes, MessageSchema, type_description_msg_to_schema,
27+
DynamicCdrCompatSerdes, DynamicMessage, MessageSchema, type_description_msg_to_schema,
2828
},
2929
};
3030
use ros_z_msgs::type_description_interfaces::{
@@ -423,7 +423,7 @@ fn test_dynamic_subscriber_from_type_description() {
423423
println!("Step 3: Creating dynamic subscriber...");
424424
let zsub = node
425425
.create_sub_impl::<DynamicMessage>("chatter", None)
426-
.with_serdes::<DynamicSerdeCdrSerdes>()
426+
.with_serdes::<DynamicCdrCompatSerdes>()
427427
.with_dyn_schema(schema.clone())
428428
.build()
429429
.expect("Failed to create dynamic subscriber");

crates/ros-z/examples/dynamic_message/interop.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
use ros_z::{
99
dynamic::{DynamicMessage, FieldType, MessageSchema},
10-
msg::{NativeCdrSerdes, ZSerdes},
10+
msg::{CdrSerdes, ZSerdes},
1111
};
1212
use ros_z_msgs::{
1313
geometry_msgs::{Point, Twist, Vector3},
@@ -52,7 +52,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
5252
);
5353

5454
// Serialize static to CDR, then deserialize as dynamic
55-
let cdr_bytes = NativeCdrSerdes::serialize_to_vec(&static_point);
55+
let cdr_bytes = CdrSerdes::serialize_to_vec(&static_point);
5656
let dynamic_point = DynamicMessage::from_cdr(&cdr_bytes, &point_schema)?;
5757
println!(
5858
"Dynamic Point: x={}, y={}, z={}\n",
@@ -76,7 +76,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
7676

7777
// Serialize dynamic to CDR, then deserialize as static
7878
let cdr_bytes = dynamic_point.to_cdr()?;
79-
let static_point = <NativeCdrSerdes as ZSerdes<Point>>::deserialize(&cdr_bytes)?;
79+
let static_point = <CdrSerdes as ZSerdes<Point>>::deserialize(&cdr_bytes)?;
8080
println!(
8181
"Static Point: x={}, y={}, z={}\n",
8282
static_point.x, static_point.y, static_point.z
@@ -89,7 +89,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
8989
};
9090
println!("Static String: \"{}\"", static_string.data);
9191

92-
let cdr_bytes = NativeCdrSerdes::serialize_to_vec(&static_string);
92+
let cdr_bytes = CdrSerdes::serialize_to_vec(&static_string);
9393
let dynamic_string = DynamicMessage::from_cdr(&cdr_bytes, &string_schema)?;
9494
println!(
9595
"Dynamic String: \"{}\"\n",
@@ -120,7 +120,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
120120
static_twist.angular.x, static_twist.angular.y, static_twist.angular.z
121121
);
122122

123-
let cdr_bytes = NativeCdrSerdes::serialize_to_vec(&static_twist);
123+
let cdr_bytes = CdrSerdes::serialize_to_vec(&static_twist);
124124
let dynamic_twist = DynamicMessage::from_cdr(&cdr_bytes, &twist_schema)?;
125125
println!("Dynamic Twist:");
126126
println!(
@@ -148,7 +148,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
148148
dynamic_msg.set("y", 2.5f64)?;
149149
dynamic_msg.set("z", 3.5f64)?;
150150

151-
let static_cdr = NativeCdrSerdes::serialize_to_vec(&static_msg);
151+
let static_cdr = CdrSerdes::serialize_to_vec(&static_msg);
152152
let dynamic_cdr = dynamic_msg.to_cdr()?;
153153

154154
println!("Static CDR: {} bytes", static_cdr.len());
@@ -175,10 +175,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
175175
);
176176

177177
// Static → CDR → Dynamic → CDR → Static
178-
let cdr1 = NativeCdrSerdes::serialize_to_vec(&original);
178+
let cdr1 = CdrSerdes::serialize_to_vec(&original);
179179
let dynamic = DynamicMessage::from_cdr(&cdr1, &point_schema)?;
180180
let cdr2 = dynamic.to_cdr()?;
181-
let recovered = <NativeCdrSerdes as ZSerdes<Point>>::deserialize(&cdr2)?;
181+
let recovered = <CdrSerdes as ZSerdes<Point>>::deserialize(&cdr2)?;
182182

183183
println!(
184184
"Recovered static: ({}, {}, {})",

crates/ros-z/examples/z_custom_message.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use ros_z::{
55
Builder, MessageTypeInfo, Result, ServiceTypeInfo,
66
context::ZContextBuilder,
77
entity::TypeHash,
8-
msg::{SerdeCdrSerdes, ZService},
8+
msg::{CdrCompatSerdes, ZService},
99
};
1010
use serde::{Deserialize, Serialize};
1111

@@ -138,7 +138,7 @@ async fn run_status_publisher(robot_id: String) -> Result<()> {
138138
let node = ctx.create_node("robot_status_publisher").build()?;
139139
let zpub = node
140140
.create_pub::<RobotStatus>("/robot_status")
141-
.with_serdes::<SerdeCdrSerdes>()
141+
.with_serdes::<CdrCompatSerdes>()
142142
.build()?;
143143

144144
let mut position_x = 0.0;
@@ -192,7 +192,7 @@ async fn run_status_subscriber() -> Result<()> {
192192
let node = ctx.create_node("robot_status_subscriber").build()?;
193193
let zsub = node
194194
.create_sub::<RobotStatus>("/robot_status")
195-
.with_serdes::<SerdeCdrSerdes>()
195+
.with_serdes::<CdrCompatSerdes>()
196196
.build()?;
197197

198198
loop {

0 commit comments

Comments
 (0)