Skip to main content

Module mutation

Module mutation 

Source
Expand description

Public typed mutation API for vault edits.

Each builder exposes two methods: plan(&self, vault) -> Result<MutationReport> produces a read-only preview without touching disk, and execute(self, vault) -> Result<MutationReport> applies the planned changes and returns the same shape of report.

The report shape is intentionally small — a vector of PlannedChange (path plus a human-readable description) and a vector of MutationError for any per-record failures. Consumers that need before/after frontmatter snapshots can compute them by running their own diff against the records on disk.

Structs§

CreateBuilder
Build a create mutation. Writes a new .md file under folder with name name (the .md extension is appended automatically).
DeleteBuilder
Build a delete mutation. Records matching filter are moved to <vault>/.trash/ by default (collision-safe). With permanent(true), files are removed entirely.
MoveBuilder
Build a move mutation. Records matching filter are relocated into to_folder (created if needed). Filename collisions at the destination surface as MutationErrors in the report.
MutationError
A failure to apply a single change.
MutationReport
A report of changes a builder would (or did) make.
PlannedChange
A single planned (or applied) change to one record.
RenameBuilder
Build a rename mutation. The single record at <folder>/<from>.md is renamed to <folder>/<to>.md, and every [[wikilink]] across the vault pointing at from is rewritten to point at to.
UpdateBuilder
Build an update mutation. The filter selects records; the chained set/unset/add_tag/remove_tag calls accumulate operations applied to each matching record’s frontmatter. Body mutations (set_body/append_body/clear_body) operate on the markdown section after the frontmatter.