Skip to main content

ElementContentHandler

Trait ElementContentHandler 

Source
pub trait ElementContentHandler {
    // Required method
    fn handle_element(
        &mut self,
        selector: usize,
        element: &mut Element<'_>,
    ) -> HandlerResult;
}
Available on crate feature html only.
Expand description

Handles matched elements during a rewrite.

Implement this on your own type — that type holds any state the handler accumulates, mutated through &mut self. selector is the index (in registration order) of the selector that matched element.

For one-off rewrites, the closure-based ElementContentHandlers builder implements this trait for you.

Required Methods§

Source

fn handle_element( &mut self, selector: usize, element: &mut Element<'_>, ) -> HandlerResult

Handles a matched element.

§Errors

Returning an error aborts the rewrite and surfaces the error from HtmlRewriter::write / end.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§