Skip to main content

apply

Function apply 

Source
pub fn apply(ops: &[DomOp]) -> Result<i64, String>
Expand description

Apply a decoded stream to the recorder — the DUMB SHIM, in Rust.

It is a for loop with no diffing, no reconciliation and no decisions of its own: every choice was made by whoever emitted the stream. That is the whole point of the format, and it is what a browser host has to be too — a host that decided anything would be a second implementation of the framework, in a language the framework does not compile to.

The EMITTER is the id authority: a created node takes the id the stream names for it, and every later record addresses it by that id. A stream names ids in the range dom::STREAM_ID_BASE opens, which the recorder never mints; below it, a stream can name only the ordinal the recorder would mint next — how a recorded op log replays into a fresh document.

All or nothing: a stream the host cannot honour — a create naming a live id, or an id the recorder mints itself out of turn — leaves the document exactly as it was.

A stream that opens a hydration (Hydrate) ends it here: answers how many of its element claims found no element of their tag — 0 for a stream that hydrated nothing. The emitter decides what a mismatch means.