Skip to main content

Card

Struct Card 

Source
pub struct Card { /* private fields */ }
Expand description

A single metadata fence parsed from a Quillmark Markdown document.

A Card is the uniform shape for both the document entry (main) fence and composable card fences. sentinel distinguishes the two.

Every card has:

  • sentinel — the QUILL reference (for main) or CARD tag (for composable).
  • frontmatter — ordered items parsed from the YAML fence body (with the sentinel key already removed).
  • body — the Markdown text that follows the closing fence, up to the next fence (or EOF).

§Card body absence

If a card block has no trailing Markdown content (e.g. the next block or EOF immediately follows the closing fence), body is the empty string "". It is never None; callers that need to distinguish “absent” from “empty” should check card.body().is_empty().

Implementations§

Source§

impl Card

Source

pub fn new(tag: impl Into<String>) -> Result<Self, EditError>

Create a new, empty composable card with the given tag.

§Invariants enforced

tag must match [a-z_][a-z0-9_]*. An invalid tag returns EditError::InvalidTagName.

The new card has no fields and an empty body.

Source

pub fn set_field( &mut self, name: &str, value: QuillValue, ) -> Result<(), EditError>

Set a frontmatter field by name. Always clears the !fill marker for that key — the “user filled in” path.

§Invariants enforced
§Validity

After a successful call the card remains valid: frontmatter contains no reserved key and the value is stored at the correct key.

§Warnings

Card mutators never modify the parent document’s warnings.

Source

pub fn set_fill( &mut self, name: &str, value: QuillValue, ) -> Result<(), EditError>

Set a frontmatter field AND mark it as a !fill placeholder — the “reset to placeholder” path. A Null value emits as key: !fill; a scalar or sequence value emits as key: !fill <value>.

§Invariants enforced

Same as Card::set_field.

§Warnings

Card mutators never modify the parent document’s warnings.

Source

pub fn remove_field(&mut self, name: &str) -> Option<QuillValue>

Remove a frontmatter field by name, returning the value if it existed.

Reserved names cannot be present in the frontmatter (the parser guarantees this), so passing a reserved name simply returns None.

§Warnings

Card mutators never modify the parent document’s warnings.

Source

pub fn replace_body(&mut self, body: impl Into<String>)

Replace the card’s Markdown body.

§Warnings

Card mutators never modify the parent document’s warnings.

Source§

impl Card

Source

pub fn new_with_sentinel( sentinel: Sentinel, frontmatter: Frontmatter, body: String, ) -> Self

Create a Card directly from a sentinel, a typed frontmatter, and a body. Does not validate the sentinel tag or any field names — callers are responsible for providing already-valid data. For user-facing construction of composable cards use Card::new (defined in edit.rs).

Source

pub fn sentinel(&self) -> &Sentinel

The sentinel discriminating this card as main or composable.

Source

pub fn tag(&self) -> String

The card tag — the CARD: value for composable cards, or the string form of the quill reference for main cards.

Source

pub fn frontmatter(&self) -> &Frontmatter

Typed frontmatter (map-keyed view and ordered item list).

Source

pub fn frontmatter_mut(&mut self) -> &mut Frontmatter

Mutable access to the frontmatter.

Source

pub fn body(&self) -> &str

Markdown body that follows this card’s closing fence.

Empty string when no trailing content is present.

Source

pub fn is_main(&self) -> bool

Returns true if this is the document entry (main) card.

Trait Implementations§

Source§

impl Clone for Card

Source§

fn clone(&self) -> Card

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 Card

Source§

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

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

impl PartialEq for Card

Source§

fn eq(&self, other: &Card) -> 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 Card

Auto Trait Implementations§

§

impl Freeze for Card

§

impl RefUnwindSafe for Card

§

impl Send for Card

§

impl Sync for Card

§

impl Unpin for Card

§

impl UnsafeUnpin for Card

§

impl UnwindSafe for Card

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.