pub struct TreeContract<S> { /* private fields */ }Expand description
A tree’s events, held to their contract in front of a sink that takes
them as one (a render that writes a document from them): one root
value, and in each object a key and then its value, each key once. A
value walked from a parsed tree keeps it by construction. A parse
streamed as it proceeds may not: it hands on a member its grammar reads
twice (JSON’s {"a":1,"a":2}, whose value keeps the last) where a tree
has one, and the rule-event adapter refuses most shapes it cannot
follow but not every one a grammar can produce. A repeated key in one
object is refused with DUPLICATE_MEMBER, and events no tree has (a
value where a key is due, a key outside an object, a close with nothing
open, a second root) with STREAMABILITY_UNKNOWN, each at the path of
the object concerned; the event is not passed on, and what to do then
is the host’s (aless falls back once to the parsed value when nothing
has been written). Each open object keeps the keys it has had, dropped
when it closes, so the cost is a lookup per key and the keys of the
objects open at once, which a parse holds in its tree already.