Skip to main content

FloatContentHandler

Trait FloatContentHandler 

Source
pub trait FloatContentHandler: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn admit(&self, content: &[NodeRef<'_, Flm>]) -> Result<(), String>;
}
Expand description

A content handler: a value that accepts a float’s content or refuses it, contributed to the service slot CONTENT_SLOT and listed by name by the float types that accept it. See the module documentation.

The registry build fails when two contributed handlers have the same name.

Required Methods§

Source

fn name(&self) -> &str

Returns the handler’s name, by which a float type lists it (FloatType::handlers): any, includegraphics, cells. Unique among the slot’s contributions.

Source

fn admit(&self, content: &[NodeRef<'_, Flm>]) -> Result<(), String>

Returns Ok(()) when the handler accepts content, the float’s content nodes in order: the direct children of its body and the paragraphs built there, without the commands \caption, \label and \nonumber, whitespace and source comments (float_body). A paragraph holding one of those commands beside other content is one content node; the float’s rule leaves the command out when it lowers the paragraph. On the raw tree that the recomposed LaTeX reads (the frozen tree that the block-structure pass has not processed; the raw tree), where no paragraph is built, the content nodes are the body’s direct children without the paragraph breaks. A handler that counts blocks (one image, one table) therefore gives the same result on both trees.

§Errors

The refusal: a description of what the handler accepts, which completes the sentence “a ‘figure’ must hold …”, for example exactly one image. The float’s rule reports the refusals only where no handler of the type accepts the content.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§