Expand description
Byte-based document-format detection for the universal observation API (Phase 12.7, ADR-0031, plan §DEC-5).
The format of a field is decided from its source bytes, never from a file
name or extension. Detection is deliberately conservative: an ambiguous or
malformed input falls back to DocumentFormat::Opaque rather than guessing,
and a format whose adapter is not compiled in cannot be detected (the input is
then Opaque), so the reported capability set always matches what the build
can actually serve.
- PDF — the byte-authoritative physical scanner admits a validated PDF
(
crate::adapter::pdf::detect). - DOCX — a valid ZIP that also carries the OPC content-types part
(
[Content_Types].xml) and a packageofficeDocumentrelationship. - EPUB — a valid ZIP that is an OCF container: the mandatory stored
mimetypemember equalsapplication/epub+zip, orMETA-INF/container.xmlnames the OCF namespace and an OPF (application/oebps-package+xml) rootfile. - ODT — a valid ZIP that is an OpenDocument (ODF) package: the mandatory
stored
mimetypemember is an OpenDocument text media type, orMETA-INF/manifest.xmldeclares one. - Opaque — everything else, including a ZIP that matches none of the above (or more than one — an ambiguous ZIP fails safe).
The detected format is recorded in the field manifest’s provenance (a
machine-readable format=<name>; prefix, see DocumentFormat::from_provenance),
so observe/find/explain can dispatch common selectors without reading the
whole source again.
Enums§
- Document
Format - A detected document format (the class of the field’s source bytes).
Constants§
- CONTAINER_
MEMBER - The mandatory OCF container descriptor member.
- CONTAINER_
NS - The OCF container-descriptor namespace.
- EPUB_
MIMETYPE - The mandatory OCF
mimetypepayload. - OPF_
MEDIA_ TYPE - The default (and only normative) package-document media type.
Functions§
- detect_
document_ format - Detect the document format of
sourcefrom its bytes alone.