Expand description
§loom-diff
Line-level diff used by both the loom CLI and the loom-gateway.
Pure functions: feed in two text blobs (or byte slices), get back
either a structured FileDiff (good for JSON / UI consumers) or
a String of git-style unified diff (good for terminal output).
Backed by the similar crate’s Myers algorithm. Binary blobs are
detected via a simple null-byte heuristic and surface as a Binary
diff variant — we don’t try to render diffs of binary content.
§Layering
loom-web · loom-gateway ← consumers
loom-diff ← THIS CRATE
─── frozen below ─────────────────────────
weave-sdk · Strand · Locus · Lens · DHT · ForumStructs§
- Diff
Hunk - A contiguous run of changes plus surrounding context.
- Diff
Line - One line in a hunk.
- File
Diff - A diff for a single path. The shape carries enough information to render git-style unified output, group changes per-hunk in a UI, and surface summary stats.
- Unified
Diff Options - Options for
unified_diff_string.
Enums§
- Binary
Reason - Why a diff couldn’t be rendered as text.
- Diff
Error - Errors produced by loom-diff.
- Diff
Line Kind - Per-line tag — additions, deletions, unchanged context lines, plus the two structural markers around a hunk gap.
- File
Diff Status - File-level status.
Functions§
- diff_
blobs - Build a
FileDifffrom two byte slices. Detects binary content (null-byte heuristic, then utf-8 check) and surfaces it as aBinarystatus without trying to render lines. - file_
diff - Convenience: diff two text strings, treating absent strings as empty (file added/deleted). Provided for tests and for callers that already hold UTF-8 strings.
- looks_
binary - Heuristic: a byte slice is “probably binary” if the first 8KB contains a null byte. This is the same check git uses.
- unified_
diff_ string - Render a
FileDiffas a unified-diff string. Identical layout togit diffso agents and humans both find this reading exactly as they expect. Empty string for unchanged files.
Type Aliases§
- Result
- Result alias.