pub struct StructElement {
pub dict: Dict,
pub reference: Option<ObjRef>,
pub kind: Vec<u8>,
pub kids: Vec<Kid>,
pub parent: Option<usize>,
}Expand description
A logical structure element.
Fields§
§dict: DictThe element’s own dictionary.
reference: Option<ObjRef>Its object reference, when it is indirect.
kind: Vec<u8>/S after the role map has been applied once, at load time. The raw
/S is not retained.
kids: Vec<Kid>The kid slots, in /K order.
parent: Option<usize>The parent element’s index in the tree’s element table, once the bottom-up walk has linked it.
Implementations§
Source§impl StructElement
impl StructElement
Sourcepub fn load_kids<R: Resolve>(dict: &Dict, page_obj_num: u32, r: &R) -> Vec<Kid>
pub fn load_kids<R: Resolve>(dict: &Dict, page_obj_num: u32, r: &R) -> Vec<Kid>
Reads an element’s kids against a page.
page_obj_num is the page being read; content kids that name a
different page become Kid::Invalid, while element kids are never
page-tested at all — that asymmetry is what lets one element tree be
reachable from every page it touches.
Sourcepub fn link_kid(
&mut self,
target: &Dict,
reference: Option<ObjRef>,
element: usize,
) -> bool
pub fn link_kid( &mut self, target: &Dict, reference: Option<ObjRef>, element: usize, ) -> bool
Points a kid slot at an element the walk has now built.
Answers whether any slot matched — a question, not a refused mutation. Matching is by object reference when both sides have one, and by dictionary equality otherwise, which is how an inline kid dictionary — having no object number to compare — still finds its slot.
Sourcepub fn obj_type<R: Resolve>(&self, r: &R) -> Vec<u8> ⓘ
pub fn obj_type<R: Resolve>(&self, r: &R) -> Vec<u8> ⓘ
/Type, coerced from whatever the key holds. Usually StructElem.
Sourcepub fn actual_text<R: Resolve>(&self, r: &R) -> String
pub fn actual_text<R: Resolve>(&self, r: &R) -> String
/ActualText, the exact replacement text.
Sourcepub fn id(&self) -> Option<Vec<u8>>
pub fn id(&self) -> Option<Vec<u8>>
/ID, read without resolving and filtered to a string.
The Option is load-bearing: a present-but-empty /ID differs from
an absent one at the API boundary, even though the dump prints neither.
Sourcepub fn lang(&self) -> Option<Vec<u8>>
pub fn lang(&self) -> Option<Vec<u8>>
/Lang, read without resolving and filtered to a string.
Not inherited — a row inside a table with /Lang /hu reports
nothing of its own.
Sourcepub fn kid_content_id(&self, index: usize) -> Option<i64>
pub fn kid_content_id(&self, index: usize) -> Option<i64>
The /MCID a kid names, or None for a kid that is not content.
This is the page-filtered reading: a content kid belonging to
another page came in as Kid::Invalid and answers None here. The
dump uses a different, unfiltered accessor
(marked_content_id_count).
A real /MCID is non-negative (ISO 32000-1 §14.7.4.2), so a Some
is always a value the file carries.