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§
Sourcetype DoctypeHandler<'handler>: FnMut(&mut Doctype<'_>) -> HandlerResult + 'handler
type DoctypeHandler<'handler>: FnMut(&mut Doctype<'_>) -> HandlerResult + 'handler
Handler type for Doctype.
Sourcetype CommentHandler<'handler>: FnMut(&mut Comment<'_>) -> HandlerResult + 'handler
type CommentHandler<'handler>: FnMut(&mut Comment<'_>) -> HandlerResult + 'handler
Handler type for Comment.
The entire content of the comment will be buffered.
Sourcetype TextHandler<'handler>: FnMut(&mut TextChunk<'_>) -> HandlerResult + 'handler
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().
Sourcetype ElementHandler<'handler>: FnMut(&mut Element<'_, '_, Self>) -> HandlerResult + 'handler
type ElementHandler<'handler>: FnMut(&mut Element<'_, '_, Self>) -> HandlerResult + 'handler
Handler type for Element.
Sourcetype EndTagHandler<'handler>: FnOnce(&mut EndTag<'_>) -> HandlerResult + 'handler
type EndTagHandler<'handler>: FnOnce(&mut EndTag<'_>) -> HandlerResult + 'handler
Handler type for EndTag.
Sourcetype EndHandler<'handler>: FnOnce(&mut DocumentEnd<'_>) -> HandlerResult + 'handler
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.