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
impl StructureTree
Sourcepub async fn load_with<S: AsyncObjectSource>(
src: &S,
trailer: &Dict,
) -> Option<StructureTree>
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.
Sourcepub fn mapped_type(&self, name: &str) -> String
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.
Sourcepub async fn ranks_with<S: AsyncObjectSource>(
&self,
src: &S,
page: &Page,
ids: &[MarkedContentId],
) -> FastMap<MarkedContentId, u32>
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.
Sourcepub async fn place_with<S: AsyncObjectSource>(
&self,
src: &S,
page: &Page,
ids: &[MarkedContentId],
) -> FastMap<MarkedContentId, Placement>
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.
Sourcepub async fn content_items_with<S: AsyncObjectSource>(
&self,
src: &S,
page: &Page,
) -> Vec<PlacedItem>
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.
Sourcepub async fn content_item_counts_with<S: AsyncObjectSource>(
&self,
src: &S,
page: &Page,
) -> (usize, usize)
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.
Sourcepub async fn place_items_with<S: AsyncObjectSource>(
&self,
src: &S,
page: &Page,
items: &[ContentItem],
) -> FastMap<ContentItem, Placement>
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
impl Clone for StructureTree
Source§fn clone(&self) -> StructureTree
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)
fn clone_from(&mut self, source: &Self)
source. Read more