Skip to main content

Module text

Module text 

Source
Expand description

Text output: where rendered fragments go.

A renderer produces many small fragments (a quote, a field, a comma) and must never hold a whole document. TextOut is the boundary: a fragment in, a failure out. WriteOut coalesces fragments to a byte budget before they reach an io::Write, so a renderer can write a character at a time without paying a system call for each, and it is where the output limit and the output-bytes metric live, because it is the one stage that knows what actually left. Join and ReplaceText are the two text combinators whose correctness depends on the difference between a logical item and a transport chunk, which is why they live beside the writer rather than in the language that uses them.

Structs§

Concat
Concatenation: a Join with no separator, under the name the design brief and the language give it.
Join
Writes a separator between logical items.
ReplaceText
Replaces every occurrence of a fixed literal, across fragment boundaries.
StringOut
A TextOut that keeps the text, for tests and small results.
WriteOut
Coalesces fragments and writes them to an io::Write.

Constants§

DEFAULT_BUDGET
The default coalescing budget of a WriteOut: large enough that a write per budget is negligible next to the parse, small enough to be invisible in a process’s memory.

Traits§

TextOut
The fragment boundary every renderer writes to, which is one of alchemy’s shared types. A consumer of text fragments.