Skip to main content

NodeTrait

Trait NodeTrait 

Source
pub trait NodeTrait<ET: EngineTypes>: Debug + Clone {
    // Required methods
    fn height(&self) -> ET::Dim;
    fn depth(&self) -> ET::Dim;
    fn width(&self) -> ET::Dim;
    fn nodetype(&self) -> NodeType;
    fn display_fmt(&self, indent: usize, f: &mut Formatter<'_>) -> Result;

    // Provided methods
    fn display(&self) -> DisplayNode<'_, ET, Self> { ... }
    fn opaque(&self) -> bool { ... }
    fn sourceref(&self) -> Option<(&SourceRef<ET>, &SourceRef<ET>)> { ... }
}
Expand description

Common trait for all nodes that end up in the final document.

Required Methods§

Source

fn height(&self) -> ET::Dim

Returns the height of the node.

Source

fn depth(&self) -> ET::Dim

Returns the depth of the node.

Source

fn width(&self) -> ET::Dim

Returns the width of the node.

Source

fn nodetype(&self) -> NodeType

Returns the type of the node, as returned by \lastnodetype.

Source

fn display_fmt(&self, indent: usize, f: &mut Formatter<'_>) -> Result

Produces a human-readable string; since nodes are deeply nested, takes an additional indent value to indent the string

Provided Methods§

Source

fn display(&self) -> DisplayNode<'_, ET, Self>

Returns a helper struct that implements Display and uses Self::display_fmt to yield a human-readable string.

Source

fn opaque(&self) -> bool

Whether this node is “opaque”; meaning: When considering a list of nodes (e.g. in \unskip or \lastbox, this node should not be considered. Useful for annotation/marker nodes some engine wants to insert, without impacting algorithms that inspect e.g. the last node of the current list.

Source

fn sourceref(&self) -> Option<(&SourceRef<ET>, &SourceRef<ET>)>

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.

Implementations on Foreign Types§

Source§

impl<ET: EngineTypes> NodeTrait<ET> for PhantomData<ET>

Source§

fn display_fmt(&self, _indent: usize, _f: &mut Formatter<'_>) -> Result

Source§

fn height(&self) -> ET::Dim

Source§

fn width(&self) -> ET::Dim

Source§

fn depth(&self) -> ET::Dim

Source§

fn nodetype(&self) -> NodeType

Source§

impl<ET: EngineTypes<CustomNode = Infallible>> NodeTrait<ET> for Infallible

Source§

fn height(&self) -> ET::Dim

Source§

fn depth(&self) -> ET::Dim

Source§

fn width(&self) -> ET::Dim

Source§

fn nodetype(&self) -> NodeType

Source§

fn display_fmt(&self, _indent: usize, _f: &mut Formatter<'_>) -> Result

Source§

fn opaque(&self) -> bool

Implementors§