Skip to main content

Table

Struct Table 

Source
pub struct Table {
    pub rows: Vec<Vec<String>>,
    pub location: Option<[u16; 4]>,
    pub structure: Option<TableStructure>,
    pub cell_blocks: Option<Vec<Vec<Vec<Node>>>>,
    pub caption: Option<String>,
    pub cell_boxes: Option<Vec<Vec<Option<[f32; 4]>>>>,
}
Expand description

A simple row-major table. By default rows[0] is the header row; a TableStructure overlay overrides that and adds column spans.

Fields§

§rows: Vec<Vec<String>>§location: Option<[u16; 4]>

Optional layout provenance: the four DocLang <location> values (x0,y0,x1,y1, each already normalized to the 0–511 resolution) emitted before the table’s cells. Set only by backends with real geometry (e.g. the spreadsheet backend, whose cell grid yields a bounding box); left None by declarative backends, which have no coordinates.

§structure: Option<TableStructure>

Optional OTSL structure overlay for backends that parse real table geometry (USPTO CALS): explicit header-row count and horizontal-span continuations. None → the default (row 0 is the header, no spans). rows still carries the full text grid (span text replicated) for Markdown/JSON; DocLang uses this overlay to emit <ched/>/<lcel/>.

§cell_blocks: Option<Vec<Vec<Vec<Node>>>>

Optional per-cell block content, parallel to rows. A rich cell (an ODF cell holding a list, several paragraphs, or a nested table) carries its DocLang blocks here; the DocLang serializer emits them after the cell token instead of the flat rows text. Markdown/JSON ignore this and render rows, so their output is unchanged. None (or an empty Vec for a given cell) → the flat text is used everywhere.

§caption: Option<String>

Optional caption (docling’s TableItem.captions): the JATS <table-wrap> label+caption, an HTML <caption>, etc. Markdown renders it as a text line before the grid; JSON emits a caption text item the table references; DocLang emits a <caption> as the table’s first child. None → the table has no caption.

§cell_boxes: Option<Vec<Vec<Option<[f32; 4]>>>>

Optional per-cell bounding boxes, same shape as Self::rows: [l, t, r, b] in page points with a top-left origin (the PDF pipeline’s native space). Set by the ML pipeline’s TableFormer paths — a spanned cell repeats its anchor’s box across the covered grid positions — and None for backends without page geometry (declarative formats, the geometric table fallback). This is API-level provenance for post-extraction repair workflows (#238: locate a cell by box, fix its OCR text, re-export); no serializer reads it, so wire outputs are unchanged by its presence.

Implementations§

Source§

impl Table

Source

pub fn cell_text(&self, row: usize, col: usize) -> Option<&str>

A cell’s text, None outside the grid.

Source

pub fn set_cell_text( &mut self, row: usize, col: usize, text: impl Into<String>, ) -> bool

Replace a cell’s text; false (and no change) outside the grid. The grid is the single source of truth for every serializer, so the new text flows into Markdown/JSON/DocLang exports as-is. Note that a spanned cell’s text is replicated across its covered positions — repairing a span means updating each covered position.

Source

pub fn cell_bbox(&self, row: usize, col: usize) -> Option<[f32; 4]>

A cell’s bounding box ([l, t, r, b], page points, top-left origin); None when the backend recorded no geometry or the position is outside the grid.

Source

pub fn set_cell_bbox(&mut self, row: usize, col: usize, bbox: [f32; 4]) -> bool

Set (or replace) a cell’s bounding box; false outside the text grid. A geometry grid is materialized on first use, shaped like Self::rows.

Source

pub fn find_cell_by_bbox(&self, bbox: [f32; 4]) -> Option<(usize, usize)>

The grid position whose recorded box overlaps bbox best (largest intersection-over-union), ties resolved in reading order. None when nothing overlaps or the table carries no geometry. This is the lookup half of the repair workflow: find the cell an external OCR box refers to, then Self::set_cell_text it.

Source

pub fn update_cell_by_bbox( &mut self, bbox: [f32; 4], text: impl Into<String>, ) -> Option<(usize, usize)>

Locate the cell overlapping bbox best and replace its text — the one-call form of the OCR-repair loop. Returns the updated position.

Trait Implementations§

Source§

impl Clone for Table

Source§

fn clone(&self) -> Table

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Table

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Table

Source§

fn default() -> Table

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Table

Source§

fn eq(&self, other: &Table) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Table

Auto Trait Implementations§

§

impl Freeze for Table

§

impl RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl UnsafeUnpin for Table

§

impl UnwindSafe for Table

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.