Skip to main content

Module lino_serialization

Module lino_serialization 

Source
Expand description

Lossless serialization of a LinkNetwork to and from links-notation text.

LinkNetwork::to_lino projects every link in the network onto a single canonical links-notation statement, keyed by the link’s numeric identifier (a doublets-style id discipline shared by text and future binary storage). LinkNetwork::from_lino reconstructs the exact same network from that text. The pair forms a round-trip: from_lino(to_lino(n)) is isomorphic to n for any network, covering references, names, types, terms, definitions, languages, source spans, parse flags, and term registration.

The emitted dialect is plain links-notation accepted by the [links_notation] 0.13 crate, so other ecosystem parsers can consume the output. Each statement has the shape:

(<id>: <ref> ... (meta: (t: <type>) (n: <0|1>) (term: <pct>) ...))

where references are decimal link ids and the trailing meta sublink carries metadata. String payloads (term, def, lang) are percent-encoded so they always form a single escape-free reference token, sidestepping the crate’s quote-escaping edge cases. The meta keys are non-numeric, so they never collide with numeric reference ids, and the references (Ref nodes) are structurally distinct from the meta sublink (a Link node) in the parsed AST.

This is distinct from LinkNetwork::parse with the "LiNo" language, which interprets human-authored links-notation into a fresh semantic network. to_lino/from_lino are an exact serialization pair for an already-built network.

Enums§

LinoSerializationError
Error returned when LinkNetwork::from_lino cannot reconstruct a network.