pub enum Element {
Title(ElementData),
Paragraph(ElementData),
Table(TableElementData),
Header(ElementData),
Footer(ElementData),
ListItem(ElementData),
Image(ImageElementData),
CodeBlock(ElementData),
KeyValue(KeyValueElementData),
}Expand description
A typed document element extracted from a PDF page.
Each variant carries its specific data plus shared ElementMetadata
for page number, bounding box, confidence, and optional font info.
Variants§
Title(ElementData)
Paragraph(ElementData)
Table(TableElementData)
Header(ElementData)
ListItem(ElementData)
Image(ImageElementData)
CodeBlock(ElementData)
KeyValue(KeyValueElementData)
Implementations§
Source§impl Element
impl Element
Sourcepub fn display_text(&self) -> String
pub fn display_text(&self) -> String
Returns a human-readable text representation of this element.
Unlike text() which returns raw content (empty for tables,
value-only for KV pairs), this method produces a complete display form:
- Tables: pipe-separated rows
- Key-Value: “key: value”
- All others: same as
text()
Sourcepub fn bbox(&self) -> &ElementBBox
pub fn bbox(&self) -> &ElementBBox
Returns the bounding box of this element on the page.
Sourcepub fn metadata(&self) -> &ElementMetadata
pub fn metadata(&self) -> &ElementMetadata
Returns the full metadata for this element.
Sourcepub fn metadata_mut(&mut self) -> &mut ElementMetadata
pub fn metadata_mut(&mut self) -> &mut ElementMetadata
Returns a mutable reference to the metadata of this element.
Sourcepub fn type_name(&self) -> &'static str
pub fn type_name(&self) -> &'static str
Returns the snake_case type name of this element variant.
Useful for logging, serialization, and metadata tagging.
Returns one of: "title", "paragraph", "table", "header",
"footer", "list_item", "image", "code_block", "key_value".
Sourcepub fn set_parent_heading(&mut self, heading: Option<String>)
pub fn set_parent_heading(&mut self, heading: Option<String>)
Set the parent heading for this element.
Sourcepub fn set_heading_path(&mut self, path: Vec<String>)
pub fn set_heading_path(&mut self, path: Vec<String>)
Set the full heading breadcrumb for this element.
Sourcepub fn row_count(&self) -> Option<usize>
pub fn row_count(&self) -> Option<usize>
Returns the number of rows if this is a Table element.
Sourcepub fn column_count(&self) -> Option<usize>
pub fn column_count(&self) -> Option<usize>
Returns the number of columns if this is a Table element.