pub trait Stomach<ET: EngineTypes> {
Show 37 methods
// Required methods
fn new(aux: &mut EngineAux<ET>, state: &mut ET::State) -> Self;
fn afterassignment(&mut self) -> &mut Option<ET::Token>;
fn data_mut(&mut self) -> &mut StomachData<ET>;
// Provided methods
fn every_top(engine: &mut EngineReferences<'_, ET>) { ... }
fn flush(engine: &mut EngineReferences<'_, ET>) -> TeXResult<(), ET> { ... }
fn do_unexpandable(
engine: &mut EngineReferences<'_, ET>,
name: PrimitiveIdentifier,
scope: CommandScope,
token: ET::Token,
apply: fn(&mut EngineReferences<'_, ET>, ET::Token) -> TeXResult<(), ET>,
) -> TeXResult<(), ET> { ... }
fn do_assignment(
engine: &mut EngineReferences<'_, ET>,
name: PrimitiveIdentifier,
token: ET::Token,
assign: fn(&mut EngineReferences<'_, ET>, ET::Token, bool) -> TeXResult<(), ET>,
global: bool,
) -> TeXResult<(), ET> { ... }
fn assign_font(
engine: &mut EngineReferences<'_, ET>,
_token: ET::Token,
f: ET::Font,
global: bool,
) -> TeXResult<(), ET> { ... }
fn assign_int_register(
engine: &mut EngineReferences<'_, ET>,
register: usize,
global: bool,
in_token: ET::Token,
) -> TeXResult<(), ET> { ... }
fn assign_dim_register(
engine: &mut EngineReferences<'_, ET>,
register: usize,
global: bool,
in_token: ET::Token,
) -> TeXResult<(), ET> { ... }
fn assign_skip_register(
engine: &mut EngineReferences<'_, ET>,
register: usize,
global: bool,
in_token: ET::Token,
) -> TeXResult<(), ET> { ... }
fn assign_muskip_register(
engine: &mut EngineReferences<'_, ET>,
register: usize,
global: bool,
in_token: ET::Token,
) -> TeXResult<(), ET> { ... }
fn assign_toks_register(
engine: &mut EngineReferences<'_, ET>,
token: ET::Token,
register: usize,
global: bool,
) -> TeXResult<(), ET> { ... }
fn assign_primitive_toks(
engine: &mut EngineReferences<'_, ET>,
token: ET::Token,
name: PrimitiveIdentifier,
global: bool,
) -> TeXResult<(), ET> { ... }
fn assign_primitive_int(
engine: &mut EngineReferences<'_, ET>,
name: PrimitiveIdentifier,
global: bool,
in_token: ET::Token,
) -> TeXResult<(), ET> { ... }
fn assign_primitive_dim(
engine: &mut EngineReferences<'_, ET>,
name: PrimitiveIdentifier,
global: bool,
in_token: ET::Token,
) -> TeXResult<(), ET> { ... }
fn assign_primitive_skip(
engine: &mut EngineReferences<'_, ET>,
name: PrimitiveIdentifier,
global: bool,
in_token: ET::Token,
) -> TeXResult<(), ET> { ... }
fn assign_primitive_muskip(
engine: &mut EngineReferences<'_, ET>,
name: PrimitiveIdentifier,
global: bool,
in_token: ET::Token,
) -> TeXResult<(), ET> { ... }
fn do_whatsit(
engine: &mut EngineReferences<'_, ET>,
name: PrimitiveIdentifier,
token: ET::Token,
read: fn(&mut EngineReferences<'_, ET>, ET::Token) -> TeXResult<Option<Box<WhatsitFunction<ET>>>, ET>,
) -> TeXResult<(), ET> { ... }
fn do_box(
engine: &mut EngineReferences<'_, ET>,
_name: PrimitiveIdentifier,
token: ET::Token,
bx: fn(&mut EngineReferences<'_, ET>, ET::Token) -> TeXResult<Either<Option<TeXBox<ET>>, BoxInfo<ET>>, ET>,
) -> TeXResult<(), ET> { ... }
fn do_char(
engine: &mut EngineReferences<'_, ET>,
token: ET::Token,
char: ET::Char,
code: CommandCode,
) -> TeXResult<(), ET> { ... }
fn do_defed_char(
engine: &mut EngineReferences<'_, ET>,
token: ET::Token,
char: ET::Char,
) -> TeXResult<(), ET> { ... }
fn do_char_in_math(
engine: &mut EngineReferences<'_, ET>,
char: ET::Char,
) -> TeXResult<(), ET> { ... }
fn do_mathchar(
engine: &mut EngineReferences<'_, ET>,
code: u32,
token: Option<ET::Token>,
) { ... }
fn close_box(
engine: &mut EngineReferences<'_, ET>,
bt: BoxType,
) -> TeXResult<(), ET> { ... }
fn maybe_switch_mode(
engine: &mut EngineReferences<'_, ET>,
scope: CommandScope,
token: ET::Token,
name: PrimitiveIdentifier,
) -> TeXResult<bool, ET> { ... }
fn open_align(
engine: &mut EngineReferences<'_, ET>,
_inner: BoxType,
between: BoxType,
) { ... }
fn close_align(engine: &mut EngineReferences<'_, ET>) -> TeXResult<(), ET> { ... }
fn add_node_m(
engine: &mut EngineReferences<'_, ET>,
node: MathNode<ET, UnresolvedMathFontStyle<ET>>,
) { ... }
fn add_node_h(engine: &mut EngineReferences<'_, ET>, node: HNode<ET>) { ... }
fn add_node_v(
engine: &mut EngineReferences<'_, ET>,
node: VNode<ET>,
) -> TeXResult<(), ET> { ... }
fn maybe_do_output(
engine: &mut EngineReferences<'_, ET>,
penalty: Option<i32>,
) -> TeXResult<(), ET> { ... }
fn do_output(
engine: &mut EngineReferences<'_, ET>,
caused_penalty: Option<i32>,
) -> TeXResult<(), ET> { ... }
fn split_vertical(
engine: &mut EngineReferences<'_, ET>,
nodes: Vec<VNode<ET>>,
target: <ET as EngineTypes>::Dim,
) -> SplitResult<ET> { ... }
fn open_paragraph(engine: &mut EngineReferences<'_, ET>, token: ET::Token) { ... }
fn close_paragraph(
engine: &mut EngineReferences<'_, ET>,
) -> TeXResult<(), ET> { ... }
fn split_paragraph(
engine: &mut EngineReferences<'_, ET>,
specs: Vec<ParLineSpec<ET>>,
children: Vec<HNode<ET>>,
start_ref: SourceReference<<<ET as EngineTypes>::File as File>::SourceRefID>,
) -> TeXResult<(), ET> { ... }
}Expand description
The Stomach is the part of the engine that processes (unexpandable)
commands, collects nodes in (horizontal or vertical) lists, and builds pages.
The vast majority of the methods implemented by this trait take a EngineReferences as their first argument
and have a default implementation already.
As such, we could have attached them to EngineReferences directly, but we put them here in a
separate trait instead so we can overwrite the methods easily - e.g. add trigger code when a paragraph is opened/closed etc.
Required Methods§
Sourcefn afterassignment(&mut self) -> &mut Option<ET::Token>
fn afterassignment(&mut self) -> &mut Option<ET::Token>
Mutable reference to the current \afterassignment Token.
Sourcefn data_mut(&mut self) -> &mut StomachData<ET>
fn data_mut(&mut self) -> &mut StomachData<ET>
The current list(s)
Provided Methods§
Sourcefn every_top(engine: &mut EngineReferences<'_, ET>)
fn every_top(engine: &mut EngineReferences<'_, ET>)
To be executed at every iteration of the top-level loop - i.e. in between all unexpandable commands
Sourcefn flush(engine: &mut EngineReferences<'_, ET>) -> TeXResult<(), ET>
fn flush(engine: &mut EngineReferences<'_, ET>) -> TeXResult<(), ET>
To be executed at the end of a document - flushes the current page
Sourcefn do_unexpandable(
engine: &mut EngineReferences<'_, ET>,
name: PrimitiveIdentifier,
scope: CommandScope,
token: ET::Token,
apply: fn(&mut EngineReferences<'_, ET>, ET::Token) -> TeXResult<(), ET>,
) -> TeXResult<(), ET>
fn do_unexpandable( engine: &mut EngineReferences<'_, ET>, name: PrimitiveIdentifier, scope: CommandScope, token: ET::Token, apply: fn(&mut EngineReferences<'_, ET>, ET::Token) -> TeXResult<(), ET>, ) -> TeXResult<(), ET>
Execute the provided Unexpandable command
Sourcefn do_assignment(
engine: &mut EngineReferences<'_, ET>,
name: PrimitiveIdentifier,
token: ET::Token,
assign: fn(&mut EngineReferences<'_, ET>, ET::Token, bool) -> TeXResult<(), ET>,
global: bool,
) -> TeXResult<(), ET>
fn do_assignment( engine: &mut EngineReferences<'_, ET>, name: PrimitiveIdentifier, token: ET::Token, assign: fn(&mut EngineReferences<'_, ET>, ET::Token, bool) -> TeXResult<(), ET>, global: bool, ) -> TeXResult<(), ET>
Execute the provided Assignment command and insert \afterassignment if necessary
Sourcefn assign_font(
engine: &mut EngineReferences<'_, ET>,
_token: ET::Token,
f: ET::Font,
global: bool,
) -> TeXResult<(), ET>
fn assign_font( engine: &mut EngineReferences<'_, ET>, _token: ET::Token, f: ET::Font, global: bool, ) -> TeXResult<(), ET>
Execute the provided Font assignment and insert \afterassignment if necessary
Sourcefn assign_int_register(
engine: &mut EngineReferences<'_, ET>,
register: usize,
global: bool,
in_token: ET::Token,
) -> TeXResult<(), ET>
fn assign_int_register( engine: &mut EngineReferences<'_, ET>, register: usize, global: bool, in_token: ET::Token, ) -> TeXResult<(), ET>
Assign a value to a count register and insert \afterassignment if necessary
Sourcefn assign_dim_register(
engine: &mut EngineReferences<'_, ET>,
register: usize,
global: bool,
in_token: ET::Token,
) -> TeXResult<(), ET>
fn assign_dim_register( engine: &mut EngineReferences<'_, ET>, register: usize, global: bool, in_token: ET::Token, ) -> TeXResult<(), ET>
Assign a value to a dimen register and insert \afterassignment if necessary
Sourcefn assign_skip_register(
engine: &mut EngineReferences<'_, ET>,
register: usize,
global: bool,
in_token: ET::Token,
) -> TeXResult<(), ET>
fn assign_skip_register( engine: &mut EngineReferences<'_, ET>, register: usize, global: bool, in_token: ET::Token, ) -> TeXResult<(), ET>
Assign a value to a skip register and insert \afterassignment if necessary
Sourcefn assign_muskip_register(
engine: &mut EngineReferences<'_, ET>,
register: usize,
global: bool,
in_token: ET::Token,
) -> TeXResult<(), ET>
fn assign_muskip_register( engine: &mut EngineReferences<'_, ET>, register: usize, global: bool, in_token: ET::Token, ) -> TeXResult<(), ET>
Assign a value to a muskip register and insert \afterassignment if necessary
Sourcefn assign_toks_register(
engine: &mut EngineReferences<'_, ET>,
token: ET::Token,
register: usize,
global: bool,
) -> TeXResult<(), ET>
fn assign_toks_register( engine: &mut EngineReferences<'_, ET>, token: ET::Token, register: usize, global: bool, ) -> TeXResult<(), ET>
Assign a value to a token register and insert \afterassignment if necessary
Sourcefn assign_primitive_toks(
engine: &mut EngineReferences<'_, ET>,
token: ET::Token,
name: PrimitiveIdentifier,
global: bool,
) -> TeXResult<(), ET>
fn assign_primitive_toks( engine: &mut EngineReferences<'_, ET>, token: ET::Token, name: PrimitiveIdentifier, global: bool, ) -> TeXResult<(), ET>
Assign a value to a primitive token list and insert \afterassignment if necessary
Sourcefn assign_primitive_int(
engine: &mut EngineReferences<'_, ET>,
name: PrimitiveIdentifier,
global: bool,
in_token: ET::Token,
) -> TeXResult<(), ET>
fn assign_primitive_int( engine: &mut EngineReferences<'_, ET>, name: PrimitiveIdentifier, global: bool, in_token: ET::Token, ) -> TeXResult<(), ET>
Assign a value to a primitive integer value and insert \afterassignment if necessary
Sourcefn assign_primitive_dim(
engine: &mut EngineReferences<'_, ET>,
name: PrimitiveIdentifier,
global: bool,
in_token: ET::Token,
) -> TeXResult<(), ET>
fn assign_primitive_dim( engine: &mut EngineReferences<'_, ET>, name: PrimitiveIdentifier, global: bool, in_token: ET::Token, ) -> TeXResult<(), ET>
Assign a value to a primitive dimension value and insert \afterassignment if necessary
Sourcefn assign_primitive_skip(
engine: &mut EngineReferences<'_, ET>,
name: PrimitiveIdentifier,
global: bool,
in_token: ET::Token,
) -> TeXResult<(), ET>
fn assign_primitive_skip( engine: &mut EngineReferences<'_, ET>, name: PrimitiveIdentifier, global: bool, in_token: ET::Token, ) -> TeXResult<(), ET>
Assign a value to a primitive skip value and insert \afterassignment if necessary
Sourcefn assign_primitive_muskip(
engine: &mut EngineReferences<'_, ET>,
name: PrimitiveIdentifier,
global: bool,
in_token: ET::Token,
) -> TeXResult<(), ET>
fn assign_primitive_muskip( engine: &mut EngineReferences<'_, ET>, name: PrimitiveIdentifier, global: bool, in_token: ET::Token, ) -> TeXResult<(), ET>
Assign a value to a primitive muskip value and insert \afterassignment if necessary
Sourcefn do_whatsit(
engine: &mut EngineReferences<'_, ET>,
name: PrimitiveIdentifier,
token: ET::Token,
read: fn(&mut EngineReferences<'_, ET>, ET::Token) -> TeXResult<Option<Box<WhatsitFunction<ET>>>, ET>,
) -> TeXResult<(), ET>
fn do_whatsit( engine: &mut EngineReferences<'_, ET>, name: PrimitiveIdentifier, token: ET::Token, read: fn(&mut EngineReferences<'_, ET>, ET::Token) -> TeXResult<Option<Box<WhatsitFunction<ET>>>, ET>, ) -> TeXResult<(), ET>
Executes a Whatsit command
Sourcefn do_box(
engine: &mut EngineReferences<'_, ET>,
_name: PrimitiveIdentifier,
token: ET::Token,
bx: fn(&mut EngineReferences<'_, ET>, ET::Token) -> TeXResult<Either<Option<TeXBox<ET>>, BoxInfo<ET>>, ET>,
) -> TeXResult<(), ET>
fn do_box( engine: &mut EngineReferences<'_, ET>, _name: PrimitiveIdentifier, token: ET::Token, bx: fn(&mut EngineReferences<'_, ET>, ET::Token) -> TeXResult<Either<Option<TeXBox<ET>>, BoxInfo<ET>>, ET>, ) -> TeXResult<(), ET>
Executes a Box command
Sourcefn do_char(
engine: &mut EngineReferences<'_, ET>,
token: ET::Token,
char: ET::Char,
code: CommandCode,
) -> TeXResult<(), ET>
fn do_char( engine: &mut EngineReferences<'_, ET>, token: ET::Token, char: ET::Char, code: CommandCode, ) -> TeXResult<(), ET>
Processes a character depending on the current TeXMode and its CommandCode
Sourcefn do_defed_char(
engine: &mut EngineReferences<'_, ET>,
token: ET::Token,
char: ET::Char,
) -> TeXResult<(), ET>
fn do_defed_char( engine: &mut EngineReferences<'_, ET>, token: ET::Token, char: ET::Char, ) -> TeXResult<(), ET>
Processes a character depending on the current TeXMode and its CommandCode
fn do_char_in_math( engine: &mut EngineReferences<'_, ET>, char: ET::Char, ) -> TeXResult<(), ET>
Sourcefn do_mathchar(
engine: &mut EngineReferences<'_, ET>,
code: u32,
token: Option<ET::Token>,
)
fn do_mathchar( engine: &mut EngineReferences<'_, ET>, code: u32, token: Option<ET::Token>, )
Processes a mathchar value (assumes we are in math mode)
Sourcefn close_box(
engine: &mut EngineReferences<'_, ET>,
bt: BoxType,
) -> TeXResult<(), ET>
fn close_box( engine: &mut EngineReferences<'_, ET>, bt: BoxType, ) -> TeXResult<(), ET>
Closes a node list belonging to a TeXBox and adds it to the
corresponding node list
Sourcefn maybe_switch_mode(
engine: &mut EngineReferences<'_, ET>,
scope: CommandScope,
token: ET::Token,
name: PrimitiveIdentifier,
) -> TeXResult<bool, ET>
fn maybe_switch_mode( engine: &mut EngineReferences<'_, ET>, scope: CommandScope, token: ET::Token, name: PrimitiveIdentifier, ) -> TeXResult<bool, ET>
Switches the current TeXMode (if necessary) by opening/closing a paragraph, or throws an error
if neither action is possible or would not result in a compatible mode.
If a paragraph is opened or closed, the provided token is requeued to be reprocessed afterwards in
horizontal/vertical mode, and false is returned (as to not process the triggering command
further). Otherwise, all is well and true is returned.
Sourcefn open_align(
engine: &mut EngineReferences<'_, ET>,
_inner: BoxType,
between: BoxType,
)
fn open_align( engine: &mut EngineReferences<'_, ET>, _inner: BoxType, between: BoxType, )
Opens an \halign or \valign
Sourcefn close_align(engine: &mut EngineReferences<'_, ET>) -> TeXResult<(), ET>
fn close_align(engine: &mut EngineReferences<'_, ET>) -> TeXResult<(), ET>
Closes an \halign or \valign
Sourcefn add_node_m(
engine: &mut EngineReferences<'_, ET>,
node: MathNode<ET, UnresolvedMathFontStyle<ET>>,
)
fn add_node_m( engine: &mut EngineReferences<'_, ET>, node: MathNode<ET, UnresolvedMathFontStyle<ET>>, )
Adds a node to the current math list (i.e. assumes we’re in math mode)
Sourcefn add_node_h(engine: &mut EngineReferences<'_, ET>, node: HNode<ET>)
fn add_node_h(engine: &mut EngineReferences<'_, ET>, node: HNode<ET>)
Adds a node to the current horizontal list (i.e. assumes we’re in (restricted) horizontal mode)
Sourcefn add_node_v(
engine: &mut EngineReferences<'_, ET>,
node: VNode<ET>,
) -> TeXResult<(), ET>
fn add_node_v( engine: &mut EngineReferences<'_, ET>, node: VNode<ET>, ) -> TeXResult<(), ET>
Adds a node to the current vertical list (i.e. assumes we’re in (internal) vertical mode)
Sourcefn maybe_do_output(
engine: &mut EngineReferences<'_, ET>,
penalty: Option<i32>,
) -> TeXResult<(), ET>
fn maybe_do_output( engine: &mut EngineReferences<'_, ET>, penalty: Option<i32>, ) -> TeXResult<(), ET>
Checks whether the output routine should occur; either because the page is
full enough, or because the provided penalty is Some
(and assumed to be <= -10000) and the page is not empty.
Sourcefn do_output(
engine: &mut EngineReferences<'_, ET>,
caused_penalty: Option<i32>,
) -> TeXResult<(), ET>
fn do_output( engine: &mut EngineReferences<'_, ET>, caused_penalty: Option<i32>, ) -> TeXResult<(), ET>
Actually calls the output routine
Sourcefn split_vertical(
engine: &mut EngineReferences<'_, ET>,
nodes: Vec<VNode<ET>>,
target: <ET as EngineTypes>::Dim,
) -> SplitResult<ET>
fn split_vertical( engine: &mut EngineReferences<'_, ET>, nodes: Vec<VNode<ET>>, target: <ET as EngineTypes>::Dim, ) -> SplitResult<ET>
Split a vertical list for the provided target height
Sourcefn open_paragraph(engine: &mut EngineReferences<'_, ET>, token: ET::Token)
fn open_paragraph(engine: &mut EngineReferences<'_, ET>, token: ET::Token)
Open a new paragraph; assumed to be called in (internal) vertical mode
Sourcefn close_paragraph(engine: &mut EngineReferences<'_, ET>) -> TeXResult<(), ET>
fn close_paragraph(engine: &mut EngineReferences<'_, ET>) -> TeXResult<(), ET>
Close a paragraph; assumed to be called in horizontal mode
Sourcefn split_paragraph(
engine: &mut EngineReferences<'_, ET>,
specs: Vec<ParLineSpec<ET>>,
children: Vec<HNode<ET>>,
start_ref: SourceReference<<<ET as EngineTypes>::File as File>::SourceRefID>,
) -> TeXResult<(), ET>
fn split_paragraph( engine: &mut EngineReferences<'_, ET>, specs: Vec<ParLineSpec<ET>>, children: Vec<HNode<ET>>, start_ref: SourceReference<<<ET as EngineTypes>::File as File>::SourceRefID>, ) -> TeXResult<(), ET>
Split a paragraph into lines and add them (as horizontal boxes) to the current vertical list
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.