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§
Provided Associated Constants§
Sourceconst MAX_SERIALIZED_SIZE_XCDR1: Option<usize> = _
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.
Sourceconst MAX_SERIALIZED_SIZE_XCDR2: Option<usize> = _
const MAX_SERIALIZED_SIZE_XCDR2: Option<usize> = _
Sourceconst IS_PLAIN: bool = _
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. Note
the FLAG is encoding-independent, not the size it qualifies: a plain
type’s bound still differs per encoding, because XCDR2 adds a
fixed-width DHEADER.
Diagnostic today: no dispatch reads it (issues 1422 / 1369). It exists
so that “fixed layout” has exactly one definition in the tree, reachable
as crate::size::is_loan_eligible; issue 0814 step 5 is the wiring that
would consume it, and 0814 argues for not building it yet. See
crate::size::SizeBound::plain for the full note.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".