Skip to main content

Crate quarb_compose

Crate quarb_compose 

Source
Expand description

Adapter composition: descend through a leaf into its content.

A filesystem’s .json file, an archive’s config.xml entry, a message’s HTML part — trees of files are full of leaves whose content is itself a tree in another notation. Composition grafts that inner tree onto the outer one: wrap any adapter in a ComposeAdapter and a leaf whose name or content says “parse me” gains the parsed arbor as its children:

/data/store.json/books/*[/price:: < 12]/title::
      └ outer (fs) ┘└──── inner (json) ────┘

The graft happens on first touch, lazily: a leaf is only read and parsed when navigation actually enters it. Detection is by extension (.json, .xml, .html/.htm/.xhtml/.svg, .csv/.tsv), else by sniffing the content’s first character; a parse failure simply leaves the leaf a leaf. Archive leaves (.zip, .tar, .tar.gz) are binary, so they graft by path rather than content — available when the outer substrate has real paths (see ComposeAdapter::with_source_paths) — and the grafted archive composes in turn, so one path runs filesystem → tar → JSON without a seam. The inner root is identified with the outer leaf node — the leaf itself answers the inner root’s children — so there is no phantom node between the file and its content.

Locators show the boundary with a bang, jar-URL style: store.json!/books/1.

Structs§

ComposeAdapter

Enums§

DocumentGraft
The level marked-up documents (.html, .htm, .md) graft at: their DOM by default, or the text level — sections, paragraphs, lists, and what the page declares about itself in its head — when the mount asks for the reader’s model (text: on an archive or directory).
SourceGraft
The level source-file leaves graft at: the syntax level (the literal parse — the default) or the code level (identifiers as names). Chosen per mount by the code: target prefix, and inherited by nested composes (an archive inside a code: mount grafts its source entries at the code level too) — the filesystem-into-declarations namespace has no seam.

Constants§

NOTATIONS
The notations a leaf can be declared to carry (spec: Grafting): the one vocabulary ?format=NOTATION on a mount and <NOTATION> on a step share, the Quarb Readings’ names of the formats. Source languages come besides, by their grammar names.
READINGS
The readings a graft operand may name as a prefix (graft(text:markdown)), as the mount prefixes spell them.

Functions§

archive_member_bytes
The bytes of an archive’s member: the hook an archive mount and every archive grafted inside another hand to ComposeAdapter::with_source_bytes.
canonical_notation
A notation’s canonical spelling: the extension synonyms read as their notation (yml yaml, md markdown, ndjson jsonl, txt text).
declared_encoding
The declaration reporter a host hands the source boundary: by the source’s name, the XML prologue for XML-family names, the HTML prescan for HTML names, both tried (prologue first) for a name that says nothing — a plain text file declares nothing either way.
is_notation
Whether a word names a notation (?format=, <NOTATION>).
notation_of_name
The canonical notation a name declares by its extension (.json, .yml, .htm, .ndjson), a source language by its grammar’s extension; None for no extension or one no reader takes.
read_source
Read one file at the source boundary under the host rule: ?encoding=, then a byte-order mark, then what the file declares, then strict UTF-8.
self_declared
The notation a text declares about itself in its first bytes (the Quarb Readings’ declared identity): an XML declaration or a DOCTYPE. Nothing else counts; a brace or a bracket is a guess, not a declaration.
source_decoding
The rule a host mount carries: ?encoding= validated at open, the reporter above.

Type Aliases§

DocumentNodes
A host’s reader for a document leaf that has no path: the outer adapter and the leaf in, its text-level model out (a row’s body under ?doc=, a model file’s document member), or None to leave the leaf to the default grafting (spec: The Corpus Reading).
DocumentReader
Any adapter, with parseable leaf content grafted as subtrees. A host’s reader for a document leaf: the path in, its text-level model out, or None to leave the leaf to the default grafting.
StringReader
A host’s reading of a lone string (spec: Grafting, graft(READING:NOTATION)): the reading’s name (text, corpus, lit, koine), the notation the string is to be read as, and the string in; its text-level model out, Some(Err) the reading’s own refusal, None where the host has no such reading.