Skip to main content

fleischwolf_core/
labels.rs

1//! Document item labels.
2//!
3//! A subset of docling-core's `DocItemLabel`. The full enum is large; we grow
4//! this as backends start emitting richer structure.
5
6/// Semantic role of a document item, mirroring docling-core's `DocItemLabel`.
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
8pub enum DocItemLabel {
9    Title,
10    SectionHeader,
11    Paragraph,
12    Text,
13    ListItem,
14    Code,
15    Formula,
16    Caption,
17    Footnote,
18    Table,
19    Picture,
20    PageHeader,
21    PageFooter,
22}
23
24impl DocItemLabel {
25    /// The wire-format string used by docling-core's JSON serialization.
26    pub fn as_str(self) -> &'static str {
27        match self {
28            DocItemLabel::Title => "title",
29            DocItemLabel::SectionHeader => "section_header",
30            DocItemLabel::Paragraph => "paragraph",
31            DocItemLabel::Text => "text",
32            DocItemLabel::ListItem => "list_item",
33            DocItemLabel::Code => "code",
34            DocItemLabel::Formula => "formula",
35            DocItemLabel::Caption => "caption",
36            DocItemLabel::Footnote => "footnote",
37            DocItemLabel::Table => "table",
38            DocItemLabel::Picture => "picture",
39            DocItemLabel::PageHeader => "page_header",
40            DocItemLabel::PageFooter => "page_footer",
41        }
42    }
43}