Skip to main content

StructureTree

Struct StructureTree 

Source
pub struct StructureTree { /* private fields */ }
Expand description

The document’s structure tree root (/StructTreeRoot), loaded once per document and asked per page where that page’s marked content sits in the tree. /MarkInfo is never consulted: a tree with leaves counts, whatever the file says about itself.

Implementations§

Source§

impl StructureTree

Source

pub async fn load_with<S: AsyncObjectSource>( src: &S, trailer: &Dict, ) -> Option<StructureTree>

Loads the catalog’s /StructTreeRoot, or None when the document declares none, or when the entry is missing or unreadable, which leaves every page in content order.

Covers ISO 32000-1 §14.7.2.

Source

pub fn mapped_type(&self, name: &str) -> String

name followed through the root’s /RoleMap until a name the map has no entry for. The map is meant to reach a standard structure type (§14.8.4) in one step; a chain is followed in case a mapped name is itself mapped, and a cycle leaves the name as written.

Covers ISO 32000-1 §14.7.3.

Source

pub async fn ranks_with<S: AsyncObjectSource>( &self, src: &S, page: &Page, ids: &[MarkedContentId], ) -> FastMap<MarkedContentId, u32>

The ranks of StructureTree::place_with alone: one page’s marked-content sequences by their position in the tree’s depth-first order, 0 for the first the tree reaches.

Covers ISO 32000-1 §14.8.2 and §14.8.2.3.

Source

pub async fn place_with<S: AsyncObjectSource>( &self, src: &S, page: &Page, ids: &[MarkedContentId], ) -> FastMap<MarkedContentId, Placement>

Places ids, one page’s marked-content sequences, in the tree: each gets its rank in the tree’s depth-first order (0 for the first the tree reaches, and so on) and the structure type of the element holding it. An id the tree never reaches (untagged content, a key the parent tree lacks, an element whose ancestry is broken) is absent, so an empty map means the page has no leaves in the tree.

The lookup goes through the parent tree (/ParentTree, keyed by /StructParents) and each element’s /P chain, so it costs the page’s own elements, never a walk of the whole tree.

Covers ISO 32000-1 §14.7.3, §14.8.2 and §14.8.2.3.

Source

pub async fn content_items_with<S: AsyncObjectSource>( &self, src: &S, page: &Page, ) -> Vec<PlacedItem>

Every content item of page the tree reaches, in the tree’s depth-first order: the marked-content sequences of the page’s own content stream (every entry of the parent tree’s array under the page’s /StructParents) and the annotations of its /Annots that carry a /StructParent. Ranks are shared, so an annotation’s place among the sequences is the place §14.8.2.3.2 gives it: right before the sequence that follows it in the tree. The sequences of a form XObject with its own /StructParents are not enumerated here; pass them to StructureTree::place_items_with when a walk of the page content has found them.

Covers ISO 32000-1 §14.7.4, §14.7.4.3, §14.7.4.4 and §14.8.2.3.2.

Source

pub async fn content_item_counts_with<S: AsyncObjectSource>( &self, src: &S, page: &Page, ) -> (usize, usize)

How many content items the parent tree files for page: the non-null entries of the array under the page’s /StructParents, and the annotations of /Annots whose /StructParent the tree has an entry for. Read from the tree’s entries alone, so no element is parsed, which makes it a summary count rather than a placement: a malformed file whose entries name elements that do not hold the items counts higher here than StructureTree::content_items_with lists.

Covers ISO 32000-1 §14.7.4.4.

Source

pub async fn place_items_with<S: AsyncObjectSource>( &self, src: &S, page: &Page, items: &[ContentItem], ) -> FastMap<ContentItem, Placement>

Places items, content items of page, in the tree: each gets its rank in the tree’s depth-first order among the items given (0 for the first the tree reaches, and so on) and the structure type of the element holding it. A sequence is found through the parent tree’s array under its /StructParents key, an object through the parent tree’s entry under the object’s own /StructParent (§14.7.4.4) and then the object reference among the element’s kids (§14.7.4.3). An item the tree never reaches is absent.

Covers ISO 32000-1 §14.7.4, §14.7.4.3 and §14.7.4.4.

Trait Implementations§

Source§

impl Clone for StructureTree

Source§

fn clone(&self) -> StructureTree

A fork: the same tree over an empty cache, which the copy fills on its own. The root and the parent entries are shared, not copied, so a page walk fanned out over threads forks the tree once per worker and the workers contend on nothing.

1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for StructureTree

Source§

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

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

impl PartialEq for StructureTree

Source§

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

Two trees are equal when they were read from the same root, whatever either has cached since.

1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more

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