Module layout

Module layout 

Source
Expand description

Layout types and algorithms for diff rendering.

This module provides the infrastructure for formatting diffs with proper alignment, coloring, and collapsing of unchanged runs.

§Architecture

  1. Format phase: Walk the Diff, format all scalar values into FormatArena
  2. Layout phase: Build LayoutNode tree, group attrs, calculate alignment
  3. Render phase: Walk tree, emit to writer with prefixes/colors/padding

Structs§

AnsiBackend
ANSI backend - emits ANSI escape codes for terminal colors.
Attr
A single attribute with its formatting info.
BuildOptions
Options for building a layout from a diff.
ChangedGroup
A group of changed attributes that fit on one -/+ line pair.
FormatArena
Arena for formatted strings.
FormattedValue
A pre-formatted value with its measurements.
JsonFlavor
JSON-style output flavor (JSONC with comments for type names).
Layout
The complete layout ready for rendering.
PlainBackend
Plain backend - no styling, just plain text.
RenderOptions
Options for rendering a layout.
RustFlavor
Rust-style output flavor.
Span
A span into the format arena’s buffer.
XmlFlavor
XML-style output flavor.

Enums§

AttrStatus
The change status of an attribute.
ElementChange
How an element changed (affects its prefix and color).
FieldPresentation
How a field should be presented in the diff output.
LayoutNode
A node in the layout tree.
SemanticColor
Semantic color meaning for diff elements.
ValueType
Type of a formatted value for color selection.

Traits§

ColorBackend
A backend that decides how to render semantic colors.
DiffFlavor
A diff output flavor that knows how to format values and present fields.

Functions§

build_layout
Build a Layout from a Diff.
group_changed_attrs
Group changed attributes into lines that fit within max line width.
render
Render a layout to a writer.
render_to_string
Render a layout to a String.