HandlerTypes

Trait HandlerTypes 

Source
pub trait HandlerTypes: Sized {
    type DoctypeHandler<'handler>: FnMut(&mut Doctype<'_>) -> HandlerResult + 'handler;
    type CommentHandler<'handler>: FnMut(&mut Comment<'_>) -> HandlerResult + 'handler;
    type TextHandler<'handler>: FnMut(&mut TextChunk<'_>) -> HandlerResult + 'handler;
    type ElementHandler<'handler>: FnMut(&mut Element<'_, '_, Self>) -> HandlerResult + 'handler;
    type EndTagHandler<'handler>: FnOnce(&mut EndTag<'_>) -> HandlerResult + 'handler;
    type EndHandler<'handler>: FnOnce(&mut DocumentEnd<'_>) -> HandlerResult + 'handler;
}
Expand description

Trait used to parameterize the type of handlers used in the rewriter.

This trait is meant to be an implementation detail for the Send-compatible type aliases. We don’t recommend writing code generic over HandlerTypes, because it makes working with closures much more difficult.

Many types like Element and ElementHandler have a hidden generic type that defaults to LocalHandlerTypes. If you need to use Send-able handlers, remove the default type by replacing it with _, e.g. Element<'_, '_, _>.

Required Associated Types§

Source

type DoctypeHandler<'handler>: FnMut(&mut Doctype<'_>) -> HandlerResult + 'handler

Handler type for Doctype.

Source

type CommentHandler<'handler>: FnMut(&mut Comment<'_>) -> HandlerResult + 'handler

Handler type for Comment.

The entire content of the comment will be buffered.

Source

type TextHandler<'handler>: FnMut(&mut TextChunk<'_>) -> HandlerResult + 'handler

Handler type for TextChunk fragments. Beware: this is tricky to use.

The text chunks are not text DOM nodes. They are fragments of text nodes, split at arbitrary points.

See TextChunk documentation for more info. See also TextChunk::last_in_text_node().

Source

type ElementHandler<'handler>: FnMut(&mut Element<'_, '_, Self>) -> HandlerResult + 'handler

Handler type for Element.

Source

type EndTagHandler<'handler>: FnOnce(&mut EndTag<'_>) -> HandlerResult + 'handler

Handler type for EndTag.

Source

type EndHandler<'handler>: FnOnce(&mut DocumentEnd<'_>) -> HandlerResult + 'handler

Handler type for DocumentEnd.

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§

Source§

impl HandlerTypes for LocalHandlerTypes

Source§

type DoctypeHandler<'h> = Box<dyn FnMut(&mut Doctype<'_>) -> Result<(), Box<dyn Error + Sync + Send>> + 'h>

Source§

type CommentHandler<'h> = Box<dyn FnMut(&mut Comment<'_>) -> Result<(), Box<dyn Error + Sync + Send>> + 'h>

Source§

type TextHandler<'h> = Box<dyn FnMut(&mut TextChunk<'_>) -> Result<(), Box<dyn Error + Sync + Send>> + 'h>

Source§

type ElementHandler<'h> = Box<dyn FnMut(&mut Element<'_, '_>) -> Result<(), Box<dyn Error + Sync + Send>> + 'h>

Source§

type EndTagHandler<'h> = Box<dyn FnOnce(&mut EndTag<'_>) -> Result<(), Box<dyn Error + Sync + Send>> + 'h>

Source§

type EndHandler<'h> = Box<dyn FnOnce(&mut DocumentEnd<'_>) -> Result<(), Box<dyn Error + Sync + Send>> + 'h>