Skip to main content

Frontmatter

Struct Frontmatter 

Source
pub struct Frontmatter {
Show 14 fields pub name: Option<String>, pub description: Option<String>, pub declarations: Vec<VarDecl>, pub params: Vec<String>, pub has_params: bool, pub allow_unused: bool, pub type_aliases: HashMap<String, VarType>, pub imports: Vec<Import>, pub consts: Vec<VarDecl>, pub env: Vec<VarDecl>, pub imported_consts: HashMap<String, Value>, pub imported_enum_type_keys: Vec<String>, pub imported_namespace_types: HashMap<String, VarType>, pub imported_type_params: HashMap<String, (String, String)>,
}
Expand description

Parsed YAML frontmatter from a .tmpl.md file.

Fields§

§name: Option<String>

Template name (matches SKILL.md name: convention).

§description: Option<String>

Description of the template’s purpose.

§declarations: Vec<VarDecl>

List of expected variable declarations (name + type + optional default).

§params: Vec<String>

Convenience: parameter names only (derived from declarations).

§has_params: bool

Whether the params: block was present in frontmatter.

§allow_unused: bool

Allow declared parameters that are never referenced in the body.

Set via allow_unused: true in frontmatter. Useful for dynamically-loaded templates where params may be conditionally used.

§type_aliases: HashMap<String, VarType>

Type aliases defined via types: in frontmatter.

Maps alias names (e.g. Priority) to their resolved VarType.

§imports: Vec<Import>

Import declarations defined via imports: in frontmatter.

§consts: Vec<VarDecl>

Constants defined via consts: in frontmatter.

§env: Vec<VarDecl>

Compile-time environment variable declarations. Provided via CompileOptions::env() at compile time.

§imported_consts: HashMap<String, Value>

Resolved constants from imports, keyed by stem.NAME.

§imported_enum_type_keys: Vec<String>

Keys in imported_consts that are enum type namespace dicts (injected from imported enum type aliases). Used by the bare-enum-access check to distinguish enum namespaces from struct constants.

§imported_namespace_types: HashMap<String, VarType>

Type information for imported namespaces, keyed by import stem.

Each entry maps a stem name (e.g. "artist") to a Struct type whose fields correspond to the imported template’s typed consts. Used by the type checker to validate field accesses and for-loop iteration over imported consts.

§imported_type_params: HashMap<String, (String, String)>

For params whose top-level type is a dotted import reference resolving to an enum (stem.TypeName), maps the param name to (import_stem, imported_type_name).

Lets codegen backends (currently the Rust proc-macro) reference the imported, already-generated type directly instead of emitting a duplicate per-template copy. Empty when no such params exist.

Implementations§

Source§

impl Frontmatter

Source

pub fn validate_field_types(&self, segments: &[Segment]) -> Vec<String>

Validate enum-variant names and field accesses across a template body, using the full set of typed declarations derived from this frontmatter.

This is the single source of truth for compile-time field-type checking, shared by the template! proc-macro and the shared cross-backend test runners, so their behavior can never drift apart.

Declarations included (all receive full field-level validation):

  • params: declarations,
  • typed import stems (imports whose consts carry type info) — this is what enables {% for row in stem.LIST_CONST %}{{ row.field }}{% /for %},
  • local consts:,
  • env: variables.

Import stems lacking const type info remain opaque (valid but untyped).

Returns a list of human-readable error strings (empty when valid).

Trait Implementations§

Source§

impl Clone for Frontmatter

Source§

fn clone(&self) -> Frontmatter

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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<(), Error>

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

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.