Skip to main content

ParserBuilder

Struct ParserBuilder 

Source
pub struct ParserBuilder { /* private fields */ }
Expand description

Configuration builder for the HTML parser.

§Example

use fast_html_parser::HtmlParser;

let parser = HtmlParser::builder()
    .max_input_size(128 * 1024 * 1024)
    .fragment_mode(true)
    .build();

let doc = parser.parse_str("<p>fragment</p>").unwrap();
assert_eq!(doc.root().text_content(), "fragment");

Implementations§

Source§

impl ParserBuilder

Source

pub fn max_input_size(self, size: usize) -> Self

Set the maximum input size in bytes.

Inputs exceeding this limit will return HtmlError::InputTooLarge. Default: 256 MiB.

Source

pub fn fragment_mode(self, enabled: bool) -> Self

Enable fragment mode.

In fragment mode the parser treats input as an HTML fragment rather than a full document. Currently this behaves identically to normal mode (the parser already handles fragments gracefully).

Source

pub fn build(self) -> HtmlParser

Consume the builder and create a configured HtmlParser.

Trait Implementations§

Source§

impl Default for ParserBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.