Skip to main content

write_dump

Function write_dump 

Source
pub fn write_dump(
    path: &Path,
    entries: &[(TableName, SymStr, Stored)],
    sources: &[String],
) -> Result<usize, String>
Expand description

Write a state diff to a dump file. Returns the number of entries successfully written.

Writes in three ordered sections, matching Perl’s TeX_Job.pool.ltxml::DumpFile which separates @cmds_early / @cmds / @cmds_late:

  1. cmds_early — M:PA / M:MPA let-aliases that are still the bootstrap snapshot’s definition of their target (e.g. \tex_let:D → \let, \tex_def:D → \def, \tex_jobname:D → \jobname). Applied first because their targets are always available (they’re in the bootstrap pool we loaded unconditionally before this dump).
  2. cmds (regular) — V / M:E / M:T / R / C / LC / UC / SC / MC / DC entries: data, expandable definitions, registers, codes — including a \let copy of a token-bodied macro whose target was redefined since, written by value.
  3. cmds_late — M:PA / M:MPA let-aliases that are the target’s current definition, defined by this dump (e.g. \bool_if_exist:NTF → \cs_if_exist:NTF). Applied last so the target is installed before the alias fires.

The early/late split requires the caller (ini_tex) to have staged a snapshot via state::stage_snapshot("bootstrap"). If no snapshot is available, all aliases are emitted as late (safe — they just wait until after regular entries).

sources are header lines naming the format files the dump was built from (latexml_engine::dump_paths::SourceStamp::header_line), which a loader checks against the TeX tree it reads packages from.