Structure
A structure (struct, also called a message) is a named data shape. It
carries typed fields.
Fields
A field is name: Type, one per line, in declaration order. A field may be
marked optional and may carry a default.
optional— the field may be absent. Without it, the field is required.= <value>— a default. Any value form a constant accepts — a literal, another constant by name, a::-path, or an f-string — plus the bare worddefault(the type's own default, e.g. an enum's first variant). Non-literals are recorded but not resolved yet.
Field types
| Kind | Examples |
|---|---|
| integers | s8 s16 s32 s64, u8 u16 u32 u64 |
| floats | f32, f64 |
| other | bool, str |
| named | another struct / enum, scoped as pkg::module::Type |
| array | Message[] (any length), u8[16] (fixed) |
| union | union(str u32) |
Use str for text. string is an accepted synonym the compiler steers you away
from; String is generated-Rust, not IDL — see
str vs string vs String.
Docstrings and annotations
A docstring (/// lines) and @key=value annotations attach to
a struct or an individual field.
Annotation values are simple — an integer, string or identifier (@internal=true).
Richer forms such as @validators=[…] are still being designed.