pub struct Frontmatter {
pub type_: Option<String>,
pub id: Option<String>,
pub created: Option<DateTime<FixedOffset>>,
pub updated: Option<DateTime<FixedOffset>>,
pub summary: Option<String>,
pub status: Option<String>,
pub tags: Vec<String>,
pub extra: BTreeMap<String, Value>,
}Expand description
The parsed YAML frontmatter of a db.md file.
The universal-contract fields are typed accessors; everything else lands in
extra as ambient context (unknown-field passthrough)
and is round-tripped verbatim. The atomic writer re-emits keys in canonical
order: type, id, created, updated, summary first, then
type-specific fields, then status / tags.
Fields§
§type_: Option<String>type — required on content files; the primary query key.
id: Option<String>id — optional; derived from the file path when absent.
created: Option<DateTime<FixedOffset>>created — RFC3339; required and auto-set on content-file create.
updated: Option<DateTime<FixedOffset>>updated — RFC3339; required and auto-maintained on content files.
summary: Option<String>summary — the one-line catalog line; required on every content file.
status: Option<String>status — optional lifecycle state.
tags — optional flat list of short scalar labels.
extra: BTreeMap<String, Value>All other frontmatter keys (type-specific + custom), preserved verbatim
in insertion-stable sorted order. Wiki-link-valued fields keep their raw
YAML form here; Frontmatter::link_fields surfaces them as
WikiLinks.
Implementations§
Source§impl Frontmatter
impl Frontmatter
Sourcepub fn parse(yaml: &str, file: &Path) -> Result<Self, ParseError>
pub fn parse(yaml: &str, file: &Path) -> Result<Self, ParseError>
Parse a YAML frontmatter block (the text between the opening and closing
--- fences, exclusive) into a Frontmatter.
Lenient on unknown keys (they go to extra);
returns ParseError::MalformedYaml only on YAML that doesn’t parse.
Sourcepub fn to_yaml(&self) -> String
pub fn to_yaml(&self) -> String
Serialize the frontmatter back to a YAML block (no --- fences) in
canonical key order. Round-trips extra verbatim.
Sourcepub fn is_content_file(path: &Path) -> bool
pub fn is_content_file(path: &Path) -> bool
True if the file is content (under sources/, records/, or wiki/)
and not an index.md. Used by validate to decide which files require a
summary. Meta files (DB.md, index.md, log.md) return false.
Sourcepub fn effective_id(&self, store_relative_path: &Path) -> String
pub fn effective_id(&self, store_relative_path: &Path) -> String
Resolve the file’s effective id: the explicit id field if present,
otherwise derived from the store-relative path (filename without .md).
Sourcepub fn set(&mut self, key: &str, value: &str) -> Result<(), ParseError>
pub fn set(&mut self, key: &str, value: &str) -> Result<(), ParseError>
Set a single frontmatter key from a string value, routing universal-
contract keys to their typed fields and everything else to
extra. Used by dbmd fm set.
Sourcepub fn link_fields(&self) -> Vec<(String, WikiLink)>
pub fn link_fields(&self) -> Vec<(String, WikiLink)>
Extract every frontmatter field whose value is a wiki-link (scalar
inline form or a block-sequence list), pairing each with its key. The
validate engine checks these against (link) schema annotations.
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 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 ==.