Skip to main content

Module wire

Module wire 

Source
Expand description

Driver-shared wire format for serialising aozora parser output.

Three driver crates (aozora-ffi, aozora-wasm, aozora-py) all need to project the borrowed-AST output to a stable byte stream. This module is the single authority for that projection — each driver calls into here and is guaranteed bit-identical output across language boundaries.

§Schema envelope

Every wire JSON has the shape

{ "schema_version": 1, "data": [ /* …entries… */ ] }

SCHEMA_VERSION is bumped on any breaking change to the serialised shape (variant additions, field renames, envelope changes). Clients that read the wire format SHOULD branch on the version to decide their handling — schema 1 makes no guarantees of forward-compatibility with later schemas.

§Stability vs. non_exhaustive

Both crate::Diagnostic and crate::AozoraNode are #[non_exhaustive] upstream so the library can add variants in minor releases. The wire format protects callers by:

  • falling back to kind: "unknown" for unrecognised variants, and
  • bumping SCHEMA_VERSION when new variants land in the wire (so a client that branches on the version can react before "unknown" shows up in production traffic).

Structs§

ContainerPairWire 🔒
DiagnosticWire 🔒
Envelope 🔒
NodeWire 🔒
OffsetWire 🔒
PairWire 🔒
SpanWire 🔒

Constants§

SCHEMA_VERSION
Wire-format schema version. Bumped on any breaking change to the serialised shape (variant additions, field renames, envelope changes).

Functions§

container_kind_str 🔒
envelope_schema 🔒
Wrap the per-entry schema in the canonical {schema_version, data: […]} envelope. The envelope shape is shared by all four wire functions; only the inner item schema varies.
schema_container_pairs
JSON Schema for the serialize_container_pairs envelope output.
schema_diagnostics
JSON Schema (draft 2020-12) describing the serialize_diagnostics envelope output.
schema_nodes
JSON Schema for the serialize_nodes envelope output.
schema_pairs
JSON Schema for the serialize_pairs envelope output.
serialize_container_pairs
Project an AozoraTree’s container open/close pair table into a { schema_version, data } JSON envelope.
serialize_diagnostics
Project a slice of Diagnostic into a { schema_version, data } JSON envelope. Every entry has the shape { kind, span: { start, end }, codepoint? }.
serialize_envelope 🔒
serialize_nodes
Project an AozoraTree’s source-keyed node side-table into a { schema_version, data } JSON envelope.
serialize_pairs
Project an AozoraTree’s pair table into a { schema_version, data } JSON envelope. Every entry has the shape { kind, open: { start, end }, close: { start, end } }.
severity_str 🔒
source_str 🔒