From 4fbaf55606e06af6e109d02b764a9190edf8c4ed Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Wed, 24 Jun 2026 12:15:07 +0200 Subject: [PATCH] docs: add documentation for `Rules::header_constraints`. --- lib/src/compiler/rules.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/src/compiler/rules.rs b/lib/src/compiler/rules.rs index 16a6fafe1..07e827414 100644 --- a/lib/src/compiler/rules.rs +++ b/lib/src/compiler/rules.rs @@ -119,6 +119,17 @@ pub struct Rules { pub(in crate::compiler) filesize_bounds: FxHashMap, + /// Map that associates a `PatternId` to a certain constraint on the + /// file header (e.g. magic bytes at offset 0), if any. + /// + /// A condition like `uint16(0) == 0x5A4D and $a` or `$mz at 0 and $a` + /// (where $mz = "MZ") only matches if the file starts with "MZ" (0x5A4D). + /// In this case, the map will contain an entry associating `$a` to a + /// `HeaderConstraint` that requires the file to start with those two + /// bytes. + /// + /// This allows skipping pattern checks entirely if the scanned data + /// doesn't start with the expected header prefix. pub(in crate::compiler) header_constraints: FxHashMap,