TomlWriteDocument functionv0.1.0
pub func TomlWriteDocument(
writer: &var TextWriter,
table: &TomlValue
) -> ! FormatError
The same tree always produces the same bytes, and a document written, read and written again produces the
same bytes the second time — which is what makes this safe to run repeatedly over a file this program owns.
It is not safe in the sense of preserving one it does not: comments, blank lines, indentation and the
spelling of a number are not in the tree, so they cannot come out of it. The output is these values laid out
by this writer, which is an equivalent document and not the same file.
The document is borrowed and nothing is allocated: it writes itself into the destination as it is walked.
Reports whatever the destination reported, unchanged, so a buffer that is merely full stays distinguishable
from a stream that has died — and stops at the first refusal rather than writing the rest of a document into a
destination that has already said no. Reports ValueOutOfRange for a table whose header path is longer than
MaximumHeaderPath.
Parameters
| Name | Type | Description |
|---|---|---|
writer | &var TextWriter | the destination |
table | &TomlValue | the document to write, borrowed for the call |
Returns: success when the whole document was accepted
Related
MaximumHeaderPath
pub const MaximumHeaderPath: uint = 1024;
How long a table's header path may be, in bytes. A header is written as text, so the path is assembled into a fixed buffer rather than a list of names, and this is that buffer. It is far past any path a person writes: reaching it takes a nesting of tables whose names add up to a kilobyte, which a document built in memory can do and one that was parsed effectively cannot.