pub trait Lower: Send + Sync {
// Required method
fn lower(
&self,
node: NodeRef<'_, Flm>,
cx: &mut LowerCx<'_>,
lw: &mut dyn Lowerer,
) -> Result<Lowering, LowerError>;
}Expand description
The implementation of a lowering rule: what to do at a node of the rule’s element.
Implement this trait and register the implementation as part of a
LoweringRule. The implementation is registered once and may run over
many nodes of many documents in parallel, so it holds only its own
configuration and does not modify its own state when it runs. Everything it reads reaches it through
the Lowerer it is handed, so every read can be checked against the
rule’s declaration.
See crate::stdlib::backends::lowering::rules for the default rules of
the structural elements, which implement this trait.
Required Methods§
Sourcefn lower(
&self,
node: NodeRef<'_, Flm>,
cx: &mut LowerCx<'_>,
lw: &mut dyn Lowerer,
) -> Result<Lowering, LowerError>
fn lower( &self, node: NodeRef<'_, Flm>, cx: &mut LowerCx<'_>, lw: &mut dyn Lowerer, ) -> Result<Lowering, LowerError>
Lowers node, a node of this rule’s element, and returns what replaces
it.
Read the tables and option types the rule declared through lw, and
build the replacement nodes through lw as well, which stages them
into cx.
§Errors
Returns LowerError when the rule cannot lower the node: a read it
did not declare, an element it did not declare that it produces, a node
structure it does not handle. See LowerError for how the lowering
stage handles each variant.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".