-
Notifications
You must be signed in to change notification settings - Fork 0
Codec Infrastructure
rusty-alto uses typed codec registries so frontends can discover formats without losing the Rust type of the object being read or written.
InputCodec<T> reads a stream or path and produces T. The standard
InputCodecRegistry contains:
| Extension | Result |
|---|---|
.irtg |
Irtg |
.tag |
Irtg |
.auto |
ExplicitWithSignature |
Codecs are looked up first by exact result type and then by metadata name or
filename extension. A frontend opening a grammar asks only for
codecs_for::<Irtg>(), so its file chooser naturally offers .irtg and
.tag, but not .auto.
Path reading is distinct from anonymous stream reading because some formats
need path context. In particular, the Tulipac codec resolves relative
#include directives against the including file.
.auto returns ExplicitWithSignature rather than bare Explicit. The
wrapper preserves the terminal signature and state names present in the file;
Explicit remains a compact numeric automaton that can be derived without
copying signatures.
OutputCodec<V> consumes an algebra's standalone public value type. The
OutputCodecRegistry stores textual codecs by exact V; any algebra with that
value type gets the same Copy/export formats.
Each algebra separately constructs one preferred display codec.
Algebra::visualize returns a VisualRepresentation, currently text, tree, or
feature structure. The GUI owns the final widget layout and interaction.
Metadata lookup never runs a codec. A GUI should:
- Build file filters or Copy menus from
CodecMetadata. - Read a selected file only after the user chooses it.
- Keep the derivation tree as the primary language-enumeration object.
- Evaluate an interpretation only when its tab is displayed or copied.
- Invoke only the selected output codec.
The detailed API and implementation checklist are maintained in
docs/codec-infrastructure.md.