Expand description
Static field schema for runtime introspection.
Each generated message type exposes its CDR field layout as a
&'static [Field] slice plus a &'static str ROS type name via the
Message trait. Backends that need to construct type descriptors at
runtime (Cyclone DDS dynamic types, FastRTPS DynamicTypeBuilder, …) walk
this static metadata instead of pulling in per-RMW codegen at compile
time.
All schema items are &'static / Copy / contain no allocations,
keeping the surface usable on no_std + alloc-free embedded targets.
§Example
use nros_serdes::schema::{Field, FieldType, Message};
/// Hand-rolled mirror of `std_msgs/msg/Int32`.
pub struct Int32 {
pub data: i32,
}
impl Message for Int32 {
const TYPE_NAME: &'static str = "std_msgs/msg/Int32";
const FIELDS: &'static [Field] = &[Field {
name: "data",
ty: FieldType::Int32,
offset: 0,
}];
}
assert_eq!(Int32::FIELDS.len(), 1);
assert!(matches!(Int32::FIELDS[0].ty, FieldType::Int32));Structs§
- Field
- One field of a ROS message, in declaration order.
- Nested
Type - Metadata for a nested struct field.
Enums§
- Field
Type - CDR / ROS-IDL type of a single field.
Constants§
- EMPTY_
STRUCT_ FIELDS - The schema of a struct that declares no fields: the one padding member
rosidl adds (
EMPTY_STRUCT_MEMBER). Codegen emits this for every empty message, so the schema describes the byte the serializer writes and a size bound, a Cyclone descriptor or a schema walk derived fromFIELDSagrees with the wire. It has no host storage, so its offset is 0. - EMPTY_
STRUCT_ MEMBER - The member rosidl gives a struct that declares none (issue 1293).
Traits§
- Message
- Trait implemented by every generated ROS message type for runtime introspection.