Skip to main content

State

Struct State 

Source
pub struct State {
Show 15 fields pub tag_properties: FxHashMap<SymStr, TagOptions>, pub indirect_model: Option<IndirectModel>, pub pending_resources: Vec<Resource>, pub verbosity: i32, pub input_encoding: Option<String>, pub search_paths: VecDeque<String>, pub graphics_paths: VecDeque<String>, pub nomathparse: bool, pub source_map: bool, pub source_table: Vec<SymStr>, pub opened_sources: FxHashSet<SymStr>, pub bindings_dispatch: Option<ResolvingBindingDispatcher>, pub extra_bindings_dispatch: Option<BindingDispatcher>, pub binding_names: Vec<&'static [(&'static str, &'static str)]>, pub label_mapping_hook: Option<LabelMappingHook>, /* private fields */
}
Expand description

The state efficiently bookkeeps the bindings in a TeX-like fashion.

Bindings associate data with keys (eg definitions with macro names) and respect TeX grouping; that is, an assignment is only in effect until the current group (opened by \bgroup) is closed (by \egroup).

Fields§

§tag_properties: FxHashMap<SymStr, TagOptions>§indirect_model: Option<IndirectModel>

an optional indirect model for long-distance relationships

§pending_resources: Vec<Resource>

Document-related resources declared during core conversion, pending until XML is finalized

§verbosity: i32§input_encoding: Option<String>§search_paths: VecDeque<String>

Seed only for the group-scoped SEARCHPATHS value-table list (read once at construction to seed it); live lookups go through get_search_paths.

§graphics_paths: VecDeque<String>

Seed only for the group-scoped GRAPHICSPATHS value-table list (read once at construction to seed it); live lookups go through get_graphics_paths.

§nomathparse: bool

flag to disable math parsing

§source_map: bool

flag enabling source-locator (--source-map) tracking + emission. Off by default; gates BOTH the per-token start capture and the per-element data-sourcepos stamping so a normal conversion pays nothing. See docs/performance/SOURCE_PROVENANCE.md.

§source_table: Vec<SymStr>

Document-level sources table for the source-map feature: ordered list of source files seen, index = the integer tag emitted in data-sourcepos (Source-Map-v3 sources style — never an inlined path). Populated lazily via source_tag() only when source_map is on. See docs/performance/SOURCE_PROVENANCE.md §0.1.

§opened_sources: FxHashSet<SymStr>

Read-log of every named source opened through Mouth::create (file paths and cached-content names; literal/anonymous mouths are not named, so not recorded). Distinct from source_table, which is populated lazily at document-construction time and filters to user sources — this log is complete and available right after a digest, which the LSP server’s warm-cache dependency snapshot relies on (lsp_server/overlay.rs::warmup_dep_snapshot).

§bindings_dispatch: Option<ResolvingBindingDispatcher>

The installed binding-resolution chain — reports the source path it loaded from (for a .rhai file binding), or None for a compiled-in binding.

§extra_bindings_dispatch: Option<BindingDispatcher>

Auxiliary convenience – extra dispatch

§binding_names: Vec<&'static [(&'static str, &'static str)]>

All (name, ext) pairs for compile-time bindings the dispatchers can load, stacked one slice per registered dispatcher. Populated at startup by each binding crate via add_binding_names, so both latexml_package and latexml_contrib contribute their classes/ styles/defs/pools to the fallback pool. Consumed by:

  • find_file(notex=true) to resolve compile-time bindings without touching the filesystem.
  • load_class’s Perl-parity prefix-match fallback (Package.pm L2702-2706) via the get_class_binding_names() filtered view.
§label_mapping_hook: Option<LabelMappingHook>

Perl: LABEL_MAPPING_HOOK — closure mapping (label, counter, norefnum) -> (refnum, id)

Implementations§

Source§

impl State

Source

pub fn new(options: StateOptions) -> Self

Source

pub fn table(&self, name: TableName) -> &Table

borrow/get the named table

Source

pub fn table_mut(&mut self, name: TableName) -> &mut Table

mutably borrow/get the named table

Source

pub fn snapshot(&self) -> FxHashMap<(TableName, SymStr), Stored>

Perl DumpFile equivalent: Take a snapshot of the current state. Returns a HashMap mapping (table_name, key) → Stored value. Only captures the front (current) value of each key. Used before processing latex.ltx to diff what changed.

Source

pub fn diff_from_snapshot( &self, snap: &FxHashMap<(TableName, SymStr), Stored>, ) -> Vec<(TableName, SymStr, Stored)>

Perl DumpFile equivalent: Compute the diff between current state and a snapshot. Returns only entries that CHANGED since the snapshot was taken. Skips entries that contain closures (Primitive, Constructor, Conditional) since those can’t be serialized — they come from Rust engine code.

Source

pub fn get_prefix(&self, prefix: &str) -> bool

gets the current value of a named prefix

Source

pub fn get_prefix_sym(&self, prefix: SymStr) -> bool

get_prefix variant with a pre-pinned SymStr (see crate::pin!) — assign_internal probes the global prefix on every unscoped assignment, so the per-call arena::pin there was pure overhead.

Source

pub fn assign_value<T: Into<Stored>, S: Into<Option<Scope>>>( &mut self, key: &str, value: T, scope: S, )

assigns a Stored value at the given key and scope

Source

pub fn lookup_value(&self, key: &str) -> Option<&Stored>

fetches a Stored value at the given key, from the Value table

Source

pub fn lookup_value_sym(&self, key: SymStr) -> Option<&Stored>

Source

pub fn lookup_value_mut(&mut self, key: &str) -> Option<&mut Stored>

mutably borrows a Stored value at the given key, from the Value table

Source

pub fn lookup_vecdeque(&self, key: &str) -> Option<&VecDeque<Stored>>

like lookup_value but only recognizes Stored::VecDequeStored

Source

pub fn lookup_font_info(&self, key: &Token) -> Result<Option<&Stored>>

Source

pub fn lookup_mapping(&self, map: &str, key: &str) -> Option<&Stored>

manage a (global) hash of values

Source

pub fn lookup_mapping_sym(&self, map_sym: SymStr, key: &str) -> Option<&Stored>

Source

pub fn lookup_mapping_keys(&self, map: &str) -> Vec<SymStr>

Source

pub fn lookup_stacked_values(&self, key: &str) -> Vec<&Stored>

Source

pub fn lookup_stacked_values_sym(&self, key: SymStr) -> Vec<&Stored>

Source

pub fn ensure_tag_property(&mut self, tag: SymStr) -> &mut TagOptions

Trait Implementations§

Source§

impl Default for State

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Send for State

Auto Trait Implementations§

§

impl !RefUnwindSafe for State

§

impl !Sync for State

§

impl !UnwindSafe for State

§

impl Freeze for State

§

impl Unpin for State

§

impl UnsafeUnpin for State

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.