1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
//! # ROS2 Message Parser
//!
//! A comprehensive Rust library for parsing ROS2 message, service, and action files.
//! This crate provides functionality to parse `.msg`, `.srv`, and `.action` files
//! according to the ROS2 IDL specification.
//!
//! ## Features
//!
//! - **Message parsing**: Parse `.msg` files with support for primitive types, arrays, and constants
//! - **Service parsing**: Parse `.srv` files with request/response separation
//! - **Action parsing**: Parse `.action` files with goal/result/feedback sections
//! - **Comprehensive validation**: Validates names, types, and values according to ROS2 standards
//! - **Error handling**: Detailed error messages for debugging parsing issues
//! - **Serde support**: Optional serialization support with the `serde` feature
//!
//! ## Quick Start
//!
//! ```rust
//! use ros2msg::{parse_message_string, parse_service_string, parse_action_string};
//!
//! // Parse a message
//! let msg_content = r#"
//! int32 x
//! int32 y
//! string name
//! "#;
//! let msg_spec = parse_message_string("geometry_msgs", "Point", msg_content)?;
//! println!("Parsed message: {}", msg_spec);
//!
//! // Parse a service
//! let srv_content = r#"
//! int32 a
//! int32 b
//! ---
//! int32 sum
//! "#;
//! let srv_spec = parse_service_string("example_msgs", "AddTwoInts", srv_content)?;
//! println!("Parsed service: {}", srv_spec);
//!
//! // Parse an action
//! let action_content = r#"
//! int32 order
//! ---
//! int32[] sequence
//! ---
//! int32[] partial_sequence
//! "#;
//! let action_spec = parse_action_string("example_msgs", "Fibonacci", action_content)?;
//! println!("Parsed action: {}", action_spec);
//! # Ok::<(), ros2msg::ParseError>(())
//! ```
//!
//! ## Modules
//!
//! - [`msg`]: ROS2 message/service/action parser (.msg, .srv, .action files)
//! - [`idl`]: ROS2 IDL parser (full IDL specification support)
//! - [`generator`]: Code generator for converting ROS2 interfaces to Rust types
//! - [`ros2args`]: ROS2 command-line arguments parser
// Public modules
/// ROS2 Message/Service/Action parser
///
/// This module handles the traditional ROS2 message format parsing for
/// `.msg`, `.srv`, and `.action` files.
/// ROS2 IDL parser
///
/// This module provides full ROS2 IDL specification support for parsing
/// advanced IDL files with complex types, modules, and annotations.
/// Code generator for ROS2 interfaces
///
/// This module provides a bindgen-style API for generating Rust code from
/// ROS2 message, service, action, and IDL files.
/// MSG/SRV/Action to IDL converter
///
/// This module converts ROS2 message, service, and action definitions to IDL format,
/// matching the behavior of rosidl_adapter.
// Re-export commonly used types and functions from the msg module
// for backward compatibility
pub use ;
/// Version information
pub const VERSION: &str = env!;
/// Parse any ROS2 interface file based on its extension
///
/// Automatically detects the file type based on the extension:
/// - `.msg` files are parsed as messages
/// - `.srv` files are parsed as services
/// - `.action` files are parsed as actions
///
/// # Arguments
///
/// * `pkg_name` - The package name containing the interface
/// * `file_path` - Path to the interface file
///
/// # Returns
///
/// Returns an `InterfaceSpecification` enum containing the parsed specification
///
/// # Example
///
/// ```rust,no_run
/// use ros2msg::{parse_interface_file, InterfaceSpecification};
/// use std::path::Path;
///
/// let spec = parse_interface_file("geometry_msgs", Path::new("Point.msg"))?;
/// match spec {
/// InterfaceSpecification::Message(msg_spec) => {
/// println!("Parsed message: {}", msg_spec.msg_name);
/// }
/// InterfaceSpecification::Service(srv_spec) => {
/// println!("Parsed service: {}", srv_spec.srv_name);
/// }
/// InterfaceSpecification::Action(action_spec) => {
/// println!("Parsed action: {}", action_spec.action_name);
/// }
/// }
/// # Ok::<(), ros2msg::ParseError>(())
/// ```