pub trait BlockStructure: Send + Sync {
// Required method
fn structure(
&self,
node: NodeRef<'_, Flm>,
cx: &mut StructureCx<'_>,
bs: &mut dyn BlockStructurer,
) -> Result<Structuring, StructureError>;
}Expand description
The block-structure hook: the aspect an element carries to lay out its own content during the layout step of the block-structure pass.
structure is called once for every node of
the element that the layout step reaches outside an opaque region, from the
root downwards, before the default handling of that node. The hook lays out
the node through the operations of bs and returns the nodes it staged, or
returns Structuring::Default to leave the node to the default handling.
See the module documentation for what a hook is for.
A hook must not give its own node to a run it lays out, because the pass
would call the hook again on it. It lays out the node’s parts instead, with
body_run,
default and
with_body.
The tree contract binds what a hook produces: a body or an argument that its declaration lays out as blocks must hold only paragraphs, block-level nodes and comments, and one laid out inline must hold no paragraph.
Required Methods§
Sourcefn structure(
&self,
node: NodeRef<'_, Flm>,
cx: &mut StructureCx<'_>,
bs: &mut dyn BlockStructurer,
) -> Result<Structuring, StructureError>
fn structure( &self, node: NodeRef<'_, Flm>, cx: &mut StructureCx<'_>, bs: &mut dyn BlockStructurer, ) -> Result<Structuring, StructureError>
Lays out node, or leaves it to the default handling.
cx is the context to stage nodes through, and bs the operations of
the layout step.
§Errors
The hook returns
StructureError::hook for a
failure of its own, and passes on unchanged the error of a
BlockStructurer operation that failed. Either error ends the pass and
leaves no tree, so a problem in the document is reported as a
diagnostic through diagnose instead.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".