pub struct Whatsit {
pub args: Vec<Option<Digested>>,
pub properties: SymHashMap<Stored>,
pub definition: Rc<dyn Definition>,
pub reversion: Option<Box<Tokens>>,
pub dual_reversion: Option<Box<SymHashMap<Tokens>>>,
pub locator: Option<Locator>,
}Expand description
Represents a digested object that can generate arbitrary elements in the XML Document.
Fields§
§args: Vec<Option<Digested>>arguments
properties: SymHashMap<Stored>additional properties, such as font information or sizing
definition: Rc<dyn Definition>the definition responsible for creating this object
reversion: Option<Box<Tokens>>cached tokens for reverting back (note that the “reversion” property is currently also used)
Boxed: this is the memo slot of a reversion cache that Rust cannot yet
fill — revert(&self) has no mutability, so the write-back in revert
stays commented out (Perl does cache here, Whatsit.pm L136-138). Held
inline it charged 24 B to every Whatsit for a value measured None on
100 % of ~601 K whatsits across five documents. Option<Box<_>> is 8 B
via the null-pointer niche and allocates nothing while None, so the slot
costs almost nothing until the cache is actually wired up (issue #361 M4).
dual_reversion: Option<Box<SymHashMap<Tokens>>>special-case reversion tokens for whatsits representing Dual math
structures. Boxed for the same reason as Whatsit::reversion — see there.
locator: Option<Locator>point of origin in the source file (None = not recorded; set under
--source-map at constructor digest, Perl Constructor.pm L106)
Implementations§
Source§impl Whatsit
impl Whatsit
Sourcepub fn is_empty(&self) -> Result<bool>
pub fn is_empty(&self) -> Result<bool>
A Whatsit is empty if it is marked empty, or space-like, or has an empty body.
Sourcepub fn set_properties(&mut self, props: HashMap<Stored>)
pub fn set_properties(&mut self, props: HashMap<Stored>)
sets a pre-assembled HashMap of properties
Sourcepub fn get_definition(&self) -> Rc<dyn Definition>
pub fn get_definition(&self) -> Rc<dyn Definition>
accessor for the definition which built this Whatsit
Sourcepub fn get_arg(&self, n: usize) -> Option<&Digested>
pub fn get_arg(&self, n: usize) -> Option<&Digested>
accessor for the argument at index n (starting from 1)
Access argument at 1-based index n (matching Perl’s $whatsit->getArg(n)).
Returns None for n == 0 (defensive — Perl convention uses 1-based indexing).
Sourcepub fn get_arg_mut(&mut self, n: usize) -> Option<&mut Digested>
pub fn get_arg_mut(&mut self, n: usize) -> Option<&mut Digested>
Mutably borrow argument at 1-based index n (matching Perl’s $whatsit->getArg(n)).
Panics if n == 0 — use 1-based indexing.
Sourcepub fn set_args(&mut self, args: Vec<Option<Digested>>)
pub fn set_args(&mut self, args: Vec<Option<Digested>>)
Sets the list of arguments for this whatsit (each arg should be Digested::List).
Sourcepub fn get_trailer(&self) -> Option<Digested>
pub fn get_trailer(&self) -> Option<Digested>
accessor for the trailer property. See whatsit::set_body
Trait Implementations§
Source§impl BoxOps for Whatsit
impl BoxOps for Whatsit
Source§fn get_properties(&self) -> &HashMap<Stored>
fn get_properties(&self) -> &HashMap<Stored>
with_properties instead.Source§fn with_properties<R, FnR>(&self, caller: FnR) -> R
fn with_properties<R, FnR>(&self, caller: FnR) -> R
Source§fn get_properties_mut(&mut self) -> &mut HashMap<Stored>
fn get_properties_mut(&mut self) -> &mut HashMap<Stored>
Source§fn get_property(&self, key: &str) -> Option<Cow<'_, Stored>>
fn get_property(&self, key: &str) -> Option<Cow<'_, Stored>>
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_string(&self) -> Result<Cow<'_, str>>
fn get_string(&self) -> Result<Cow<'_, str>>
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 get_body(&self) -> Result<Option<Digested>>
fn get_body(&self) -> Result<Option<Digested>>
Source§fn compute_size(
&self,
options: HashMap<Stored>,
) -> Result<(Dimension, Dimension, Dimension)>
fn compute_size( &self, options: HashMap<Stored>, ) -> Result<(Dimension, Dimension, Dimension)>
Source§fn unlist(&self) -> Vec<Digested>
fn unlist(&self) -> Vec<Digested>
fn unlist_ref(&self) -> Vec<Cow<'_, Digested>>
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 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)fn get_property_string(&self, key: &str) -> String
Source§fn has_property(&self, key: &str) -> bool
fn has_property(&self, key: &str) -> bool
Source§fn get_property_bool(&self, key: &str) -> bool
fn get_property_bool(&self, key: &str) -> bool
Stored::Bool)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)>
pad{top,bottom,left,right} to the computed dimensions. This is the SAFE
part of computeSizeStore — additive and inert until the app layer sets a
pad* property (display math \abovedisplayskip/\belowdisplayskip,
\overline/\underline 2pt, items/equations). The riskier requested-vs-
computed merge + full-spec bypass + isEmpty are deliberately NOT included
here — a mechanical port of those regressed (Rust boxes don’t use
width/height/depth uniformly as “requested box size”); see SYNC_STATUS U2.Source§impl Object for Whatsit
impl Object for Whatsit
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().