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. 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
Any adapter, with parseable leaf content grafted as subtrees.