pub struct Frontmatter { /* private fields */ }Expand description
Ordered list of frontmatter items with map-keyed convenience accessors.
Top-level YAML comments live in items as FrontmatterItem::Comment.
Comments inside nested mappings/sequences live in nested_comments,
keyed by structural path; the emitter re-injects them at the matching
position when serialising the value tree.
Implementations§
Source§impl Frontmatter
impl Frontmatter
Sourcepub fn from_index_map(map: IndexMap<String, QuillValue>) -> Self
pub fn from_index_map(map: IndexMap<String, QuillValue>) -> Self
Build from an IndexMap of fields (no comments, no fill markers).
Sourcepub fn from_items(items: Vec<FrontmatterItem>) -> Self
pub fn from_items(items: Vec<FrontmatterItem>) -> Self
Build from a pre-computed item list.
Sourcepub fn from_items_with_nested(
items: Vec<FrontmatterItem>,
nested_comments: Vec<NestedComment>,
) -> Self
pub fn from_items_with_nested( items: Vec<FrontmatterItem>, nested_comments: Vec<NestedComment>, ) -> Self
Build from a pre-computed item list and a set of nested comments.
Sourcepub fn nested_comments(&self) -> &[NestedComment]
pub fn nested_comments(&self) -> &[NestedComment]
Comments captured inside nested mappings/sequences. The emitter re-injects these at the matching position when serialising the value tree.
Sourcepub fn items(&self) -> &[FrontmatterItem]
pub fn items(&self) -> &[FrontmatterItem]
Ordered iterator over raw items (including comments).
Sourcepub fn iter(&self) -> impl Iterator<Item = (&String, &QuillValue)> + '_
pub fn iter(&self) -> impl Iterator<Item = (&String, &QuillValue)> + '_
Iterator over (key, value) pairs, skipping comments. Preserves order.
Sourcepub fn keys(&self) -> impl Iterator<Item = &String> + '_
pub fn keys(&self) -> impl Iterator<Item = &String> + '_
Iterator over field keys, skipping comments. Preserves order.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if there are no field items (comments are ignored).
Sourcepub fn get(&self, key: &str) -> Option<&QuillValue>
pub fn get(&self, key: &str) -> Option<&QuillValue>
Look up a field value by key.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Returns true if a field with this key is present.
Sourcepub fn insert(
&mut self,
key: impl Into<String>,
value: QuillValue,
) -> Option<QuillValue>
pub fn insert( &mut self, key: impl Into<String>, value: QuillValue, ) -> Option<QuillValue>
Insert or update a field. Always clears the fill marker (field is no
longer a placeholder). Preserves position for existing keys; appends
new keys at the end. Adjacent comments are untouched.
Sourcepub fn insert_fill(
&mut self,
key: impl Into<String>,
value: QuillValue,
) -> Option<QuillValue>
pub fn insert_fill( &mut self, key: impl Into<String>, value: QuillValue, ) -> Option<QuillValue>
Insert or update a field and mark it as a !fill placeholder. Preserves
position for existing keys; appends new keys at the end.
Sourcepub fn remove(&mut self, key: &str) -> Option<QuillValue>
pub fn remove(&mut self, key: &str) -> Option<QuillValue>
Remove a field by key and return its value. Adjacent comments stay where they are.
Sourcepub fn is_fill(&self, key: &str) -> bool
pub fn is_fill(&self, key: &str) -> bool
Returns true if a field with this key is marked !fill.
Sourcepub fn to_index_map(&self) -> IndexMap<String, QuillValue>
pub fn to_index_map(&self) -> IndexMap<String, QuillValue>
Project the field portion into an IndexMap<String, QuillValue>.
Comments are dropped; fill markers are lost. Preserves order.
Trait Implementations§
Source§impl Clone for Frontmatter
impl Clone for Frontmatter
Source§fn clone(&self) -> Frontmatter
fn clone(&self) -> Frontmatter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Frontmatter
impl Debug for Frontmatter
Source§impl Default for Frontmatter
impl Default for Frontmatter
Source§fn default() -> Frontmatter
fn default() -> Frontmatter
Source§impl<'a> IntoIterator for &'a Frontmatter
impl<'a> IntoIterator for &'a Frontmatter
Source§type Item = (&'a String, &'a QuillValue)
type Item = (&'a String, &'a QuillValue)
Source§type IntoIter = FilterMap<Iter<'a, FrontmatterItem>, fn(&'a FrontmatterItem) -> Option<(&'a String, &'a QuillValue)>>
type IntoIter = FilterMap<Iter<'a, FrontmatterItem>, fn(&'a FrontmatterItem) -> Option<(&'a String, &'a QuillValue)>>
Source§impl PartialEq for Frontmatter
impl PartialEq for Frontmatter
Source§fn eq(&self, other: &Frontmatter) -> bool
fn eq(&self, other: &Frontmatter) -> bool
self and other values to be equal, and is used by ==.