Trait HtmlAstNode

Source
pub trait HtmlAstNode {
    // Required methods
    fn node_tag_name() -> &'static str;
    fn from_element(element: &Element) -> Self
       where Self: Sized;
    fn generate_tokens<FChildParser>(
        &self,
        context: &mut NodeContext<'_, FChildParser>,
        ignore: &mut Vec<String>,
    ) -> TokenStream
       where FChildParser: FnMut(&[Element], &mut TokenStream, &mut Vec<String>, &str) -> TokenStream;
}
Expand description

Trait for all HTML abstract syntax tree (AST) nodes. Defines how a node is created from an Element and how it generates Rust TokenStream.

Required Methods§

Source

fn node_tag_name() -> &'static str

Returns the XML tag name for this node type (e.g., “if”, “select”).

Source

fn from_element(element: &Element) -> Self
where Self: Sized,

Creates an instance of the node from a generic Element. This method will extract necessary attributes and validate them. Can panic if attributes are missing, similar to original code’s expect().

Source

fn generate_tokens<FChildParser>( &self, context: &mut NodeContext<'_, FChildParser>, ignore: &mut Vec<String>, ) -> TokenStream
where FChildParser: FnMut(&[Element], &mut TokenStream, &mut Vec<String>, &str) -> TokenStream,

Generates the Rust TokenStream for this specific AST node. The ignore vector is passed directly to allow modification by calling nodes (e.g. for scope).

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.

Implementors§