pub(crate) struct Tree {
header: Text,
root: Entry,
footer: Text,
}Expand description
A parsed YAML document.
Block mappings are split into entries. A flow mapping with entries is kept as raw text until an edit enters it, and then it prints in block style. Everything else is kept as raw text. Printing the tree gives the source back, with edits applied.
Fields§
§header: Text§root: EntryImplementations§
Source§impl Tree
impl Tree
Sourcepub(crate) fn parse(text: &str) -> Result<Self, DocumentError>
pub(crate) fn parse(text: &str) -> Result<Self, DocumentError>
Read a YAML document with a single document in it.
§Errors
Returns an error when the text is not valid YAML or holds more than one document.
pub(super) fn new(header: Text, root: Value, footer: Text) -> Self
Sourcepub(crate) fn is_opaque_at(&self, path: &KeyPath) -> bool
pub(crate) fn is_opaque_at(&self, path: &KeyPath) -> bool
Whether the node at path is a mapping the tree cannot edit.
Sourcepub(crate) fn collapse_empty_root(&mut self)
pub(crate) fn collapse_empty_root(&mut self)
Print an empty root mapping as {}. Call after editing.
Sourcepub(super) fn into_mapping(self) -> Option<Mapping>
pub(super) fn into_mapping(self) -> Option<Mapping>
The root mapping, when the document has one the tree can edit.
Trait Implementations§
Source§impl Editable for Tree
impl Editable for Tree
type Node = Entry
Source§fn header_text(&self) -> &str
fn header_text(&self) -> &str
The text of the header comment of this document.
Source§fn leading(&self) -> (&str, &str)
fn leading(&self) -> (&str, &str)
The text before the first entry as the document root holds it and as
the first entry holds it. A format that keeps all of it in one place
returns an empty root text.
Source§fn set_leading(&mut self, applied: Applied<'_>)
fn set_leading(&mut self, applied: Applied<'_>)
Put the leading text of an applied header in place.
Source§fn apply_header(&mut self, desired: &Self, existing: Existing)
fn apply_header(&mut self, desired: &Self, existing: Existing)
Replace the leading comment block of this document with the header
of
desired.impl Eq for Tree
impl StructuralPartialEq for Tree
Auto Trait Implementations§
impl Freeze for Tree
impl RefUnwindSafe for Tree
impl Send for Tree
impl Sync for Tree
impl Unpin for Tree
impl UnsafeUnpin for Tree
impl UnwindSafe for Tree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.