Skip to main content

ItemTree

Struct ItemTree 

Source
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

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

pub fn last_text(&self) -> Option<usize>

The last live text-bucket item (docling’s doc.texts[-1]).

Source

pub fn bucket_index(&self, id: usize) -> usize

How many items of a bucket precede id — its #/{bucket}/N index.

Source

pub fn table_count(&self) -> usize

The number of tables created so far (docling’s len(doc.tables)).

Trait Implementations§

Source§

impl Clone for ItemTree

Source§

fn clone(&self) -> ItemTree

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 ItemTree

Source§

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

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

impl Default for ItemTree

Source§

fn default() -> ItemTree

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

impl PartialEq for ItemTree

Source§

fn eq(&self, other: &ItemTree) -> 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 ItemTree

Auto Trait Implementations§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.