Skip to main content

gaze_document/layout/
mod.rs

1//! Layout / reading-order contract surface.
2//!
3//! Concrete extraction (column detection, multi-page reading order, table
4//! flattening) lands in follow-up PRs. This module reserves the
5//! [`ReadingOrder`] handle so adopters can pin against the eventual contract.
6
7use crate::DocumentError;
8
9/// Reading-order handle for a single document.
10///
11/// Pre-0.1 placeholder — single-page bundles flow through [`crate::clean`]
12/// without consulting this type. Multi-page output will route through
13/// [`ReadingOrder::infer`] in a follow-up PR.
14#[non_exhaustive]
15pub struct ReadingOrder {
16    _private: (),
17}
18
19impl ReadingOrder {
20    /// Build a reading-order handle.
21    ///
22    /// # Errors
23    /// Always returns [`DocumentError::NotImplemented`] until the
24    /// multi-page PR lands. Single-page bundles never call this; the
25    /// placeholder fails loudly so adopters cannot stumble into silent
26    /// empty-order output (Axis 1 fail-closed).
27    pub fn new() -> Result<Self, DocumentError> {
28        Err(DocumentError::NotImplemented(
29            "ReadingOrder::new (multi-page deferred to follow-up PR)",
30        ))
31    }
32
33    /// Infer reading order from raw page payloads.
34    ///
35    /// # Errors
36    /// Returns [`DocumentError::NotImplemented`] until the multi-page PR
37    /// lands. Single-page bundles do not need this path.
38    pub fn infer(_pages: &[&[u8]]) -> Result<Self, DocumentError> {
39        Err(DocumentError::NotImplemented(
40            "ReadingOrder::infer (multi-page deferred to follow-up PR)",
41        ))
42    }
43}