Expand description
Compares the IDs of two Tilewright worlds (docs/spec/DIFF.md).
Games keep IDs in saves, server state and scripts: planes, zones,
anchors, stairwells, definitions, render layers and object uids. Removing or renaming
one breaks whatever refers to it. A Snapshot holds the IDs of one
world, read from a source tree or a content pack, with a fingerprint of
each one’s content. diff compares two snapshots and reports which IDs
were removed, added and renamed, and which removals an Allowlist
declares intended.
let limits = tilewright_diff::Limits::default();
let old = tilewright_diff::load(Path::new("baseline.twpack"), &limits)?;
let new = tilewright_diff::load(Path::new("content"), &limits)?;
let report = tilewright_diff::diff(&old, &new, &tilewright_diff::Allowlist::default());
print!("{}", report.to_text());
if report.breaking() {
eprintln!("IDs were removed or renamed");
}Structs§
- Added
- Allowlist
- Intended removals and renames, at most one for each old ID.
- Allowlist
Error - Why an allowlist could not be read: the first problem found.
- Limits
- Bounds on what a snapshot may hold. A snapshot keeps every ID of its world with a fingerprint, so its memory grows with its IDs.
- Removed
- Renamed
- Report
- The result of
crate::diff. Every list is sorted. - Side
- Where a snapshot came from.
- Snapshot
- The IDs of one world, each with a fingerprint of its content.
- Unused
- An allowlist entry that did not apply.
Enums§
- Allowance
- One allowlist entry.
- Basis
- Why a removed ID and a new one are reported as a rename.
- Error
- Why a side of a comparison could not be read.
- Input
- What a side of a comparison was read from.
- Kind
- A kind of ID. Kinds sort by name.
- Reason
Constants§
- ALLOWLIST_
FORMAT - The
formatof an allowlist document. - DEFAULT_
MAXIMUM_ IDS - The default
Limits::maximum_ids. - FORMAT
- The
formatof a JSON report.
Functions§
- diff
- Compares two snapshots. Every list in the report is sorted, so the same snapshots and allowlist always give the same report.
- load
- Reads one side of a comparison: a content pack when
pathis a file, which is opened and fully verified with the default bounds first, and otherwise a source tree, which is loaded and validated with the default bounds. The snapshot holds at mostlimits.maximum_idsIDs; seeLimitsfor what that bounds.