Skip to main content

write

Function write 

Source
pub fn write(
    parsed: &Parsed,
    tree: &Tree,
    ctx: &WriteCtx<'_>,
    out: &mut DecodeBuf,
) -> Result<(), WriteError>
Expand description

Writes parsed through tree (the object’s own tree, or a nodes= override: keys are then matched by name), appending to out, a buffer on the object’s input’s meter that charges before it grows (a value read with a negative length can name the same bytes many times, so the output can be far larger than the value; plan section 3.15). Its work is the open’s of out’s meter, counted as it goes whatever the outcome (OpenWork): VALUE_WORK for each value it writes or child it skips, but a primitive, which counts the bytes it writes, as a read counts a primitive run’s; and each step of finding a child’s entry that builds no value (super::STEP_WORK, and the bytes of a name it compares or hashes). A write is refused before it starts once the open’s work has passed its allowance, and fails once its own work takes the open past it (the module docs of super, “Work”).