pub trait DomParser<'de> {
type Error: Error + 'static;
// Required methods
fn next_event(&mut self) -> Result<Option<DomEvent<'de>>, Self::Error>;
fn peek_event(&mut self) -> Result<Option<&DomEvent<'de>>, Self::Error>;
fn skip_node(&mut self) -> Result<(), Self::Error>;
// Provided methods
fn current_span(&self) -> Option<Span> { ... }
fn is_lenient(&self) -> bool { ... }
fn format_namespace(&self) -> Option<&'static str> { ... }
fn capture_raw_node(&mut self) -> Result<Option<Cow<'de, str>>, Self::Error> { ... }
}Expand description
A parser that emits DOM events from a tree-structured document.
Implementations exist for HTML (using html5gum) and XML parsers.
Required Associated Types§
Required Methods§
Sourcefn next_event(&mut self) -> Result<Option<DomEvent<'de>>, Self::Error>
fn next_event(&mut self) -> Result<Option<DomEvent<'de>>, Self::Error>
Get the next event from the document.
Returns Ok(None) when the document is fully parsed.
Provided Methods§
Sourcefn current_span(&self) -> Option<Span>
fn current_span(&self) -> Option<Span>
Get the current span in the source document, if available.
Sourcefn is_lenient(&self) -> bool
fn is_lenient(&self) -> bool
Whether this parser is lenient about text in unexpected places.
HTML parsers return true - text without a corresponding field is silently discarded.
XML parsers return false - text without a corresponding field is an error.
Sourcefn format_namespace(&self) -> Option<&'static str>
fn format_namespace(&self) -> Option<&'static str>
Returns the format namespace for this parser (e.g., “xml”, “html”).
This is used to select format-specific proxy types when a field has
#[facet(xml::proxy = XmlProxy)] or similar format-namespaced proxies.
Returns None by default, which falls back to format-agnostic proxies.
Sourcefn capture_raw_node(&mut self) -> Result<Option<Cow<'de, str>>, Self::Error>
fn capture_raw_node(&mut self) -> Result<Option<Cow<'de, str>>, Self::Error>
Capture the current node as raw markup and skip past it.
Must be called right after receiving a NodeStart event. Returns the raw source text for the entire element (from opening tag through closing tag).
Returns None if raw capture is not supported by this parser.