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_VERSIONwhen new variants land in the wire (so a client that branches on the version can react before"unknown"shows up in production traffic).
Structs§
- Container
Pair 🔒Wire - Diagnostic
Wire 🔒 - Envelope 🔒
- Node
Wire 🔒 - Offset
Wire 🔒 - Pair
Wire 🔒 - Span
Wire 🔒
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_pairsenvelope output. - schema_
diagnostics - JSON Schema (draft 2020-12) describing the
serialize_diagnosticsenvelope output. - schema_
nodes - JSON Schema for the
serialize_nodesenvelope output. - schema_
pairs - JSON Schema for the
serialize_pairsenvelope 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
Diagnosticinto 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 🔒