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, string |
| named | another struct / enum, scoped as pkg::module::Type |
| array | Message[] (any length), u8[16] (fixed) |
| union | union(string u32) |
Use string for text; str and String are not Comline types — see
Text.
Docstrings
A docstring (/// lines) and @key=value annotations attach to
a struct or an individual field.
Annotations
An annotation's value is one of three forms:
- A single value: an integer, a string,
true/falseor a name (@timeout_ms = 1000). - A list of calls, for
@validators(@validators = [StringBounds(min_chars = 3)]). - A dictionary of
key = valueentries, for an annotation with several settings, such as@framing(@framing = { name = "jsonrpc", method_names = qualified }).
TODO: annotations might not apply to structures, only fields