Expand description
Format detection. Magic bytes first, extension as tiebreak.
Detection resolves every file against the versioned format table in
rules/formats.toml. Magic bytes win when they map to a table
entry. When magic bytes are inconclusive, or point at a format the
table does not name, the file extension decides. Both views are
recorded, with a mismatch flag when they disagree.
Structs§
- Detection
- The detection outcome for one file.
- Format
Def - One entry in the format table.
- Format
Table - The parsed format table from
rules/formats.toml.
Constants§
- UNKNOWN_
FORMAT - The detected id for a file neither magic bytes nor the extension can place.
Functions§
- declared_
format - The format id a file’s extension declares, when the table knows it.
- detect_
bytes_ with_ warnings - Detects the format of in-memory bytes against the table, using a path hint only for the declared extension or basename.
- detect_
file - Detects the format of one file against the table.
- detect_
file_ with_ warnings - Detects the format of one file and collects detection warnings.