Skip to main content

Message

Trait Message 

Source
pub trait Message: Sized {
    const TYPE_NAME: &'static str;
    const FIELDS: &'static [Field];
    const MAX_SERIALIZED_SIZE_XCDR1: Option<usize> = _;
    const MAX_SERIALIZED_SIZE_XCDR2: Option<usize> = _;
    const IS_PLAIN: bool = _;
}
Expand description

Trait implemented by every generated ROS message type for runtime introspection.

Provides the ROS type name plus the static field schema. Implementors also typically implement crate::Serialize + crate::Deserialize for the CDR fast path; this trait is the introspection surface used by RMW backends that build type descriptors at runtime.

All items are &'static, so the trait is fully usable in no_std + alloc-free environments. The blanket bound is just Sized — no Serialize / Deserialize super-bound, so verification-only mirror types (nros-ghost-types) and CycloneDDS-only “descriptor probe” types can implement Message without dragging the CDR codecs in.

Required Associated Constants§

Source

const TYPE_NAME: &'static str

ROS topic-type name in package/msg/Type form (e.g. "std_msgs/msg/String").

Wire-level DDS encoding ("std_msgs::msg::dds_::String_") is the concern of the per-RMW topic-name renderer, not this trait.

Source

const FIELDS: &'static [Field]

Field schema in declaration order.

Provided Associated Constants§

Source

const MAX_SERIALIZED_SIZE_XCDR1: Option<usize> = _

Phase 380 — the largest this type can serialize to, per encoding, or None when it is unbounded.

PROVIDED, computed from Self::FIELDS by crate::size, so a generated message gets it for free and cannot state a number that disagrees with its own schema. There are two because there are genuinely two: the encodings pad 8-byte primitives differently and XCDR2 adds a DHEADER per struct, so one constant would be silently wrong for one of them.

None means “no bound exists”, never “unknown” — do not size a buffer from a fallback. For an unbounded type ask size::serialized_size about the message in hand instead.

Source

const MAX_SERIALIZED_SIZE_XCDR2: Option<usize> = _

Source

const IS_PLAIN: bool = _

No variable-length member anywhere: the size above is EXACT and the type is loan-eligible (phase-380 W5).

Encoding-independent — “has a String or an unbounded sequence” does not depend on how it is packed — so unlike the sizes there is only one.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§