pub struct Digested(/* private fields */);Expand description
An Rc-guarded abstraction for any object encountered at the “digested” phase of processing
Implementations§
Source§impl Digested
impl Digested
Sourcepub fn try_set_property<T: Into<Stored>>(&self, key: &str, value: T) -> bool
pub fn try_set_property<T: Into<Stored>>(&self, key: &str, value: T) -> bool
Set a property unless the box is borrowed — being absorbed (Document::absorb holds it while its constructor
runs); false then. Perl’s store always lands (Box.pm:168-171).
Sourcepub fn data(&self) -> &DigestedData
pub fn data(&self) -> &DigestedData
immutably borrow the inner Digested data
Sourcepub fn strong_count(&self) -> usize
pub fn strong_count(&self) -> usize
Number of live Digested handles sharing this box (diagnostics: a box
still referenced after its fragment was absorbed and dropped is retained
somewhere else).
Sourcepub fn as_ptr(&self) -> *const DigestedData
pub fn as_ptr(&self) -> *const DigestedData
Identity of the shared allocation (diagnostics: visit each box once).
Sourcepub fn cycle_fingerprint(&self) -> u64
pub fn cycle_fingerprint(&self) -> u64
A content-aware but COST-BOUNDED fingerprint for the stomach cycle guard
(crate::cycle_guard).
Design tension: it must (a) distinguish boxes by content so two
different boxes that merely share a shape (e.g. two Lists of equal
length but different children) don’t collide into a false cycle, yet
(b) be cheap on the digestion path. We reconcile both with a hard
node budget: at most FP_BUDGET sub-boxes are ever visited (a
depth-first sample of the content), so cost is O(1) per box regardless
of how large or deeply nested the structure is, while the sample is rich
enough that real content differences change the hash. (It is also only
ever invoked once box_list has already blown past the stomach guard’s
activation size, so ordinary conversions never pay for it at all.)
NOT a stable cross-process hash — for in-run loop detection only.
Sourcepub fn estimate_bytes(&self) -> usize
pub fn estimate_bytes(&self) -> usize
A COST-BOUNDED estimate of the heap bytes this digested box (and its
nested content) occupies. Used by the stomach’s portable
memory-budget guard (crate::stomach) to detect a runaway by the
resource that actually matters — bytes — rather than box COUNT, since
per-box weight varies several-fold (a bare text box vs a deeply nested
\hbox{\raise…\hbox{…}}). Traversal is capped at EB_BUDGET sub-boxes
(depth-first) so the estimate stays O(1) per box; deeply nested boxes
beyond the budget are under-counted, which is safe (the guard only needs
a monotone lower bound to catch unbounded growth).
Sourcepub fn value_of(&self) -> i64
pub fn value_of(&self) -> i64
Obtain the i64 value of the digested object, iff it wraps a RegisterValue
Sourcepub fn get_dimension(&self) -> Option<Dimension>
pub fn get_dimension(&self) -> Option<Dimension>
Obtain a Dimension from the digested object, iff it wraps a RegisterValue
Sourcepub fn pt_value(&self, prec: Option<u8>) -> f64
pub fn pt_value(&self, prec: Option<u8>) -> f64
Obtain the f64 value of the digested object, iff it wraps a RegisterValue
Sourcepub fn any<F>(&self, check: F) -> bool
pub fn any<F>(&self, check: F) -> bool
Predicate check - true if any element of the current object passes the check
Sourcepub fn all<F>(&self, check: F) -> bool
pub fn all<F>(&self, check: F) -> bool
Predicate check - true if all elements of the current object passes the check
Sourcepub fn is_empty(&self) -> Result<bool>
pub fn is_empty(&self) -> Result<bool>
Predicate check - delegates to .is_empty() of the underlying data
Sourcepub fn is_strut(&self) -> bool
pub fn is_strut(&self) -> bool
A strut: something that occupies height but leaves no ink — an
invisible zero-width \vrule, or an \hbox/\vbox whatsit whose
content_box holds only struts and skippable material (latex.ltx:12596’s
\strutbox, which \strut \unhcopys into every TeXbook
\halign{\strut#&…} template cell — halignatt.tex). An alignment treats
a strut-only cell as empty (Perl’s isrule test, Alignment.pm L459-462,
extended; its isSkippable L514 already looks through content_box).
Guard: perfect_kernel_batch54::zero_width_vrule_is_a_strut_not_a_border.
Sourcepub fn is_empty_paragraph_cell(&self) -> bool
pub fn is_empty_paragraph_cell(&self) -> bool
A table cell’s boxes that hold nothing but a paragraph cell (p{}/m{}/b{}, the \lx@tabular@p@ box,
tex_tables.rs) with a skippable body, and skippable material: a cell a row span may cover, though
Self::is_skippable (Perl’s isSkippable) counts the box as content. KNOWN_PERL_ERRORS #1015.
Sourcepub fn is_skippable(&self) -> bool
pub fn is_skippable(&self) -> bool
Check if all items are “empty” or only spaces or otherwise skippable in a table cell. Perl: isSkippable (Alignment.pm L484-508)
Sourcepub fn raw_tokens(&self) -> Option<&Tokens>
pub fn raw_tokens(&self) -> Option<&Tokens>
Provide a way of emulating an Undigested argument, by requesting
raw tokens, only when they are preserved – empty otherwise.
Sourcepub fn to_attribute(&self) -> String
pub fn to_attribute(&self) -> String
builds an attribute-friendly String form of the digested object, suitable for XML attributes
(Perl toAttribute): a list joins its items’ forms (List.pm:85-87); a whatsit whose definition
gives an attribute form — carried here as its attributeForm property, which Perl also reads first
(Whatsit.pm:217-228) — is that text, \hskip’s spaces (TeX_Glue.pool.ltxml:85) rather than the
reverted \enskip; anything else is its string.
Sourcepub fn untex(&self) -> Result<String>
pub fn untex(&self) -> Result<String>
Reverts a digested object to Tokens and extracts a TeX-near string representation of its
content
pub fn alignment_cell(&self) -> Option<&RefCell<Alignment>>
Trait Implementations§
Source§impl BoxOps for Digested
impl BoxOps for Digested
Source§fn get_font(&self) -> Result<Option<Rc<Font>>>
fn get_font(&self) -> Result<Option<Rc<Font>>>
The box’s font as a SHARED handle.
This used to return Cow<'_, Font>, which was a false promise on exactly
the path that matters: the payloads live behind a RefCell, so a
Cow::Borrowed cannot outlive the borrow guard and every arm was forced
through Cow::Owned(v.into_owned()) — a deep Font clone on every call,
even though Tbox/List/Whatsit all already hold an Rc<Font>.
That clone was the single largest allocation in a conversion. Measured
2026-07-29 with --features dhat-heap on 100k words of plain prose:
Rc<Font>::new accounted for 392 MB of the 840 MB peak (47 %) across
1,196,000 blocks of 344 B — one per box absorbed — reached via
List::new ← append_node_box ← open_text ← absorb. The digested
boxes themselves came to 164 MB, so the font attached to each box cost
2.4x the box. No caller ever used Cow’s one advantage (to_mut).
Source§fn compute_size(
&self,
options: HashMap<Stored>,
) -> Result<(Dimension, Dimension, Dimension)>
fn compute_size( &self, options: HashMap<Stored>, ) -> Result<(Dimension, Dimension, Dimension)>
Note the difference between calling compute_size on a Digested object, and calling it on a
concrete box type. When called on Digested it will opt for caching the computed sizes,
but when called on the concrete types it will always compute sizes fresh.
Source§fn unlist(&self) -> Vec<Digested>
fn unlist(&self) -> Vec<Digested>
fn unlist_ref(&self) -> Vec<Cow<'_, Digested>>
Source§fn be_absorbed(&self, document: &mut Document) -> Result<Vec<Node>>
fn be_absorbed(&self, document: &mut Document) -> Result<Vec<Node>>
Document XML - returning the corresponding nodesSource§fn with_properties<R, FnR>(&self, caller: FnR) -> R
fn with_properties<R, FnR>(&self, caller: FnR) -> R
Source§fn set_property<T: Into<Stored>>(&mut self, key: &str, value: T)
fn set_property<T: Into<Stored>>(&mut self, key: &str, value: T)
Stored types for values)Source§fn set_memo_property<T: Into<Stored>>(&mut self, key: &str, value: T)
fn set_memo_property<T: Into<Stored>>(&mut self, key: &str, value: T)
BoxOps::set_property for a memo — a value the box can compute again — which a box busy elsewhere (being
absorbed) does without, where Perl’s plain hash store (Box.pm:294-296) always lands.Source§fn get_property(&self, key: &str) -> Option<Cow<'_, Stored>>
fn get_property(&self, key: &str) -> Option<Cow<'_, Stored>>
Source§fn get_string(&self) -> Result<Cow<'_, str>>
fn get_string(&self) -> Result<Cow<'_, str>>
Source§fn has_property(&self, key: &str) -> bool
fn has_property(&self, key: &str) -> bool
Source§fn get_body(&self) -> Result<Option<Digested>>
fn get_body(&self) -> Result<Option<Digested>>
Source§fn get_property_bool(&self, key: &str) -> bool
fn get_property_bool(&self, key: &str) -> bool
Stored::Bool)Source§fn be_absorbed_mut(&mut self, _document: &mut Document) -> Result<Vec<Node>>
fn be_absorbed_mut(&mut self, _document: &mut Document) -> Result<Vec<Node>>
Alignment only)Source§fn get_tokens(&self) -> Option<&Tokens>
fn get_tokens(&self) -> Option<&Tokens>
Source§fn get_properties(&self) -> &HashMap<Stored>
fn get_properties(&self) -> &HashMap<Stored>
with_properties instead.Source§fn get_properties_mut(&mut self) -> &mut HashMap<Stored>
fn get_properties_mut(&mut self) -> &mut HashMap<Stored>
fn get_property_string(&self, key: &str) -> String
Source§fn get_property_mut(&mut self, key: &str) -> Option<&mut Stored>
fn get_property_mut(&mut self, key: &str) -> Option<&mut Stored>
Source§fn get_width(
&self,
options: Option<HashMap<Stored>>,
) -> Result<Option<RegisterValue>>
fn get_width( &self, options: Option<HashMap<Stored>>, ) -> Result<Option<RegisterValue>>
Source§fn set_height<T: Into<Stored>>(&mut self, width: T)
fn set_height<T: Into<Stored>>(&mut self, width: T)
Source§fn get_height(&self) -> Option<RegisterValue>
fn get_height(&self) -> Option<RegisterValue>
Source§fn get_depth(&self) -> Option<RegisterValue>
fn get_depth(&self) -> Option<RegisterValue>
Source§fn get_size(
&mut self,
options: Option<HashMap<Stored>>,
) -> Result<(Dimension, Dimension, Dimension, Dimension, Dimension, Dimension)>
fn get_size( &mut self, options: Option<HashMap<Stored>>, ) -> Result<(Dimension, Dimension, Dimension, Dimension, Dimension, Dimension)>
Digested::get_size for a variant with interior mutability which caches the box sizeSource§fn compute_size_and_cache(
&mut self,
options: HashMap<Stored>,
) -> Result<(Dimension, Dimension, Dimension)>
fn compute_size_and_cache( &mut self, options: HashMap<Stored>, ) -> Result<(Dimension, Dimension, Dimension)>
computeSizeStore (Box.pm:266-297). A box whose size is completely
specified keeps that size, and its contents are not measured (:275-281):
width, height and depth all given, a space’s width, or a vertical space’s
height or depth. A pgf picture declares its size, and sizing a box that
holds one walked every drawing box of it (pgf-spectraPreviewDataLSE, 56kq).
Perl #2798 (S5, padding slice): the size then takes any requested
pad{top,bottom,left,right} (display math
\abovedisplayskip/\belowdisplayskip, \overline/\underline 2pt,
items/equations). Not ported: a partly specified size keeping its given
parts over the computed ones, and isEmpty — a mechanical port of those
regressed (Rust boxes don’t use width/height/depth uniformly as “requested
box size”; docs/archive/UPSTREAM_SYNC_2767_to_2833_2026-06-26.md, U2 and
slice S5); tracked with K18 in docs/SYNC_STATUS.md.Source§impl From<RegisterValue> for Digested
impl From<RegisterValue> for Digested
Source§fn from(value: RegisterValue) -> Digested
fn from(value: RegisterValue) -> Digested
Source§impl Object for Digested
impl Object for Digested
Source§fn revert(&self) -> Result<Tokens>
fn revert(&self) -> Result<Tokens>
The source tokens this digested value came from — digestion run backwards, delegated to whichever variant is held.
What \meaning-style introspection and the tex attribute are built on:
a construct that has already become boxes, a whatsit or an alignment can
still show the LaTeX that produced it. A Postponed variant is already
tokens and reverts to itself.
fn stringify(&self) -> String
Source§fn get_locator(&self) -> Option<Locator>
fn get_locator(&self) -> Option<Locator>
None is the honest
“no recorded source position” (replacing the old Locator::default()
file!()/line!() sentinel). For “where the parser is now” (error
reporting, box creation), use the free fn gullet::get_locator().fn isa_box(&self) -> bool
fn is_expandable(&self) -> bool
fn is_definition(&self) -> bool
fn is_comment(&self) -> bool
fn be_digested(self) -> Result<Digested>
Source§fn get_origin(&self) -> DefinitionOrigin
fn get_origin(&self) -> DefinitionOrigin
definition::origin). The
default is Unknown, which counts as LaTeXML’s own.