pub trait IsBlock<'src>:
HasSpan<'src>
+ Clone
+ Debug
+ Eq
+ PartialEq {
// Required methods
fn content_model(&self) -> ContentModel;
fn context(&self) -> CowStr<'src>;
// Provided method
fn nested_blocks(&'src self) -> Iter<'src, Block<'src>> { ... }
}Expand description
Block elements form the main structure of an AsciiDoc document, starting with the document itself.
A block element (aka block) is a discrete, line-oriented chunk of content in an AsciiDoc document. Once parsed, that chunk of content becomes a block element in the parsed document model. Certain blocks may contain other blocks, so we say that blocks can be nested. The converter visits each block in turn, in document order, converting it to a corresponding chunk of output.
This trait implements many of the same core methods as the Block enum but provides a mechanism for third-party code to extend the behavior of blocks.
Required Methods§
Sourcefn content_model(&self) -> ContentModel
fn content_model(&self) -> ContentModel
Returns the ContentModel for this block.
Sourcefn context(&self) -> CowStr<'src>
fn context(&self) -> CowStr<'src>
Returns the context for this block.
A block’s context is also sometimes referred to as a name, such as an example block, a sidebar block, an admonition block, or a section.
Every block has a context. The context is often implied by the syntax, but can be declared explicitly in certain cases. The context is what distinguishes one kind of block from another. You can think of the context as the block’s type.
For that reason, the context is not defined as an enumeration, but rather as a string type that is optimized for the case where predefined constants are viable.
Provided Methods§
Sourcefn nested_blocks(&'src self) -> Iter<'src, Block<'src>>
fn nested_blocks(&'src self) -> Iter<'src, Block<'src>>
Returns an iterator over the nested blocks contained within this block.
Many block types do not have nested blocks so the default implementation returns an empty iterator.
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.