Skip to main content

Frontmatter

Struct Frontmatter 

Source
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

Source

pub fn new() -> Self

Create an empty Frontmatter.

Source

pub fn from_index_map(map: IndexMap<String, QuillValue>) -> Self

Build from an IndexMap of fields (no comments, no fill markers).

Source

pub fn from_items(items: Vec<FrontmatterItem>) -> Self

Build from a pre-computed item list.

Source

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.

Source

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.

Source

pub fn items(&self) -> &[FrontmatterItem]

Ordered iterator over raw items (including comments).

Source

pub fn iter(&self) -> impl Iterator<Item = (&String, &QuillValue)> + '_

Iterator over (key, value) pairs, skipping comments. Preserves order.

Source

pub fn keys(&self) -> impl Iterator<Item = &String> + '_

Iterator over field keys, skipping comments. Preserves order.

Source

pub fn len(&self) -> usize

Number of field items (comments excluded).

Source

pub fn is_empty(&self) -> bool

Returns true if there are no field items (comments are ignored).

Source

pub fn get(&self, key: &str) -> Option<&QuillValue>

Look up a field value by key.

Source

pub fn contains_key(&self, key: &str) -> bool

Returns true if a field with this key is present.

Source

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.

Source

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.

Source

pub fn remove(&mut self, key: &str) -> Option<QuillValue>

Remove a field by key and return its value. Adjacent comments stay where they are.

Source

pub fn is_fill(&self, key: &str) -> bool

Returns true if a field with this key is marked !fill.

Source

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

Source§

fn clone(&self) -> Frontmatter

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Frontmatter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Frontmatter

Source§

fn default() -> Frontmatter

Returns the “default value” for a type. Read more
Source§

impl<'a> IntoIterator for &'a Frontmatter

Source§

type Item = (&'a String, &'a QuillValue)

The type of the elements being iterated over.
Source§

type IntoIter = FilterMap<Iter<'a, FrontmatterItem>, fn(&'a FrontmatterItem) -> Option<(&'a String, &'a QuillValue)>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for Frontmatter

Source§

fn eq(&self, other: &Frontmatter) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Frontmatter

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.