1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! Null-hypothesis check for the Phase D tag-linking experiment.
//!
//! If Revit's Global/Latest stream encoded classes by ASCII name (like JSON or
//! XML), well-known class names like `ADocument`, `Symbol`, `HostObj`,
//! `Category` would appear as literal strings inside the decompressed bytes.
//!
//! This probe demonstrates that they *don't* — class names live only in
//! `Formats/Latest`, confirming Revit uses integer class tags for data-side
//! references. Run it before `link_schema.rs` to understand why tag-based
//! linkage is the correct approach.
use rvt::{
RevitFile, compression,
streams::{FORMATS_LATEST, GLOBAL_LATEST},
};
fn main() -> anyhow::Result<()> {
let path = std::env::args()
.nth(1)
.expect("usage: probe_link <file.rvt|.rfa>");
let mut rf = RevitFile::open(&path)?;
let raw = rf.read_stream(GLOBAL_LATEST)?;
// Global/Latest: 8-byte custom header + truncated-gzip body.
let decomp = compression::inflate_at(&raw, 8)?;
println!(
"Global/Latest: {} bytes raw → {} bytes decompressed ({:.1}x)",
raw.len(),
decomp.len(),
decomp.len() as f64 / raw.len() as f64
);
let probes = [
"ADocument",
"DBView",
"Symbol",
"HostObj",
"Category",
"ElementId",
"ModelIdentity",
"PathType",
];
for p in probes {
let bytes = p.as_bytes();
let count = decomp.windows(bytes.len()).filter(|w| *w == bytes).count();
println!(" ASCII '{p}' (len {}): {count} occurrences", bytes.len());
}
// For comparison: the same probes against Formats/Latest where class
// names DO exist.
let schema_raw = rf.read_stream(FORMATS_LATEST)?;
// Formats/Latest: gzip header at offset 0 (no custom wrapper).
let schema_decomp = compression::inflate_at(&schema_raw, 0)?;
println!(
"\nFormats/Latest: {} bytes decompressed",
schema_decomp.len()
);
for p in ["ADocument", "DBView", "Symbol", "HostObj", "Category"] {
let bytes = p.as_bytes();
let count = schema_decomp
.windows(bytes.len())
.filter(|w| *w == bytes)
.count();
println!(" ASCII '{p}' in Formats/Latest: {count} occurrences");
}
Ok(())
}