pub enum SourceDocument {
Empty,
Content {
root: Table,
trailing: String,
},
}Expand description
One of the two documents a merge is given, after parsing.
Zero bytes and “parsed, but declares no keys” are different states, and only
byte length decides which. A file holding # notes to self is not empty: it
has text that has to survive the merge, and default keys are written in
beneath it. Only a file of no length has nothing to preserve.
Variants§
Empty
Zero bytes. Nothing to parse, nothing to keep.
Content
Text that parsed. The root table may hold no keys, which is a document with content all the same.
Implementations§
Source§impl SourceDocument
impl SourceDocument
Sourcepub fn parse(src: &str) -> Result<Self, TomlError>
pub fn parse(src: &str) -> Result<Self, TomlError>
Parses a document, keeping nothing but the root table and the trailing
text. Spans are discarded; use SourceDocument::parse_with_spans for
the document diagnostics point into.
Sourcepub fn parse_with_spans(src: &str) -> Result<(Self, SpanIndex), TomlError>
pub fn parse_with_spans(src: &str) -> Result<(Self, SpanIndex), TomlError>
Parses a document and harvests its key spans first.
Document::into_mut resolves spans into owned strings and the
span() accessors then return None, so positions have to be taken
before the conversion. There is no way back.
Sourcepub fn trailing(&self) -> &str
pub fn trailing(&self) -> &str
The text after the last element, empty for a zero-byte document.
Sourcepub fn has_text_but_no_keys(&self) -> bool
pub fn has_text_but_no_keys(&self) -> bool
Whether the document parsed and declares no keys. A zero-byte document is not one of these: it has no text at all.