Expand description
Binary command buffer parser and mutation applicator.
Reads a command buffer produced by the JS CommandBuffer class, converts
commands into arena mutations, and returns the rebuilt arena.
§Wire format
All multi-byte integers are little-endian. A command is one CMD_*
byte plus [nodeId: u32]; structural commands then carry a
[payloadType: u8][len: u32][payload…] sub-tree. The command, payload,
op-stream, and property-kind byte values (with their operand layouts) are
declared once in satteri-layout-codegen/src/schema.rs and generated into
generated/wire_constants.rs here and
packages/satteri/src/generated/wire-constants.ts on the JS side.
The MDAST and HAST command paths are deliberately separate functions
(apply_mdast_commands, apply_hast_commands). Numeric node_type
values overlap between the two arenas (e.g. mdast Paragraph=1 collides
with HastNodeType::Element=1), so a single dispatcher trying to handle
both kinds would silently misroute nodes. The phantom-typed Arena<K>
signature on each entry point makes a cross-kind call a compile error.
Structs§
- Mdast
Command Options - Options controlling how MDAST command buffers are applied.
Functions§
- apply_
hast_ commands - Apply a command buffer to a HAST arena. Set-property mutations are
applied in-place; structural mutations are collected as
Patch<Hast>objects and applied in place viaapply_patches_in_place. Errors if a patch is stranded inside a removed/replaced subtree;apply_hast_commands_lenientdrops it instead. - apply_
hast_ commands_ lenient - Like
apply_hast_commands, but rather than erroring when a patch targets a node inside a removed/replaced subtree, drops it and returns the dropped anchors — mirroringapply_mdast_commands_lenient. Such a patch is moot: the plugin discarded that subtree. A passed-through child keeps its identity (via_ref) and so is never stranded this way. - apply_
mdast_ commands - Apply a command buffer to an MDAST arena. Set-property mutations are
applied in-place; structural mutations are collected as
Patch<Mdast>objects and applied in place viaapply_patches_in_place. - apply_
mdast_ commands_ lenient - Like
apply_mdast_commands, but rather than erroring when a patch targets a node inside a removed/replaced subtree, drops it and returns the dropped anchors. Such a patch is moot — the plugin discarded that subtree. A passed-through child is not dropped: it rides a_refplaceholder that splices it back with its id intact, so a transform queued on a nested node (e.g. a:::tipinside a:::note) still applies, in the same pass. - apply_
mdast_ commands_ lenient_ with_ options - Like
apply_mdast_commands_lenient, with explicit command application options. - apply_
mdast_ commands_ with_ options - Like
apply_mdast_commands, with explicit command application options.