pub struct ItemTree {
pub items: Vec<TreeItem>,
pub body: Vec<usize>,
}Expand description
docling’s item tree in creation order (see the module docs).
Fields§
§items: Vec<TreeItem>Every item, indexed by creation order — which is how docling numbers
#/texts/N, #/groups/N, … within each bucket.
body: Vec<usize>The body’s children, as item indices.
Implementations§
Source§impl ItemTree
impl ItemTree
Sourcepub fn add(
&mut self,
parent: Option<usize>,
layer: Option<ContentLayer>,
kind: TreeKind,
) -> usize
pub fn add( &mut self, parent: Option<usize>, layer: Option<ContentLayer>, kind: TreeKind, ) -> usize
Append an item under parent (None = body) on layer, registering
it as its parent’s last child — docling’s add_* calls do exactly that.
Sourcepub fn add_with_prov(
&mut self,
parent: Option<usize>,
layer: Option<ContentLayer>,
kind: TreeKind,
prov: TreeProv,
) -> usize
pub fn add_with_prov( &mut self, parent: Option<usize>, layer: Option<ContentLayer>, kind: TreeKind, prov: TreeProv, ) -> usize
add with the item’s provenance — docling’s
add_text(…, prov=prov).
Sourcepub fn append(&mut self, other: ItemTree)
pub fn append(&mut self, other: ItemTree)
Append every item of other after this tree’s, renumbering its
indices (parents, children, comments, table/picture caption and
rich-cell refs) and adding its body children to this body — so a
backend can build independent fragments in parallel (one per PPTX
slide) and still hand the export one tree in creation order, exactly
as if it had been built sequentially.
Sourcepub fn reparent(&mut self, id: usize, new_parent: Option<usize>)
pub fn reparent(&mut self, id: usize, new_parent: Option<usize>)
Move id under new_parent, dropping it from its current parent’s
children and appending it to the new one’s — docling’s
group_cell_elements re-parenting of a rich cell’s items.
Sourcepub fn delete(&mut self, id: usize)
pub fn delete(&mut self, id: usize)
Remove id from the tree — docling’s delete_items, which the DOCX
backend uses to drop the empty text item a blank spacer paragraph left
between two items of a resumed list. The item leaves its parent’s
children and is neither numbered nor written; its slot stays so the
indices held elsewhere stay valid.
Sourcepub fn last_text(&self) -> Option<usize>
pub fn last_text(&self) -> Option<usize>
The last live text-bucket item (docling’s doc.texts[-1]).
Sourcepub fn bucket_index(&self, id: usize) -> usize
pub fn bucket_index(&self, id: usize) -> usize
How many items of a bucket precede id — its #/{bucket}/N index.
Sourcepub fn table_count(&self) -> usize
pub fn table_count(&self) -> usize
The number of tables created so far (docling’s len(doc.tables)).