Struct Parser

Source
pub struct Parser {
    pub format: ParseFormat,
}
Expand description

Parsing API wrapper for libxml2

Fields§

§format: ParseFormat

The ParseFormat for this parser

Implementations§

Source§

impl Parser

Source

pub fn default_html() -> Self

Create a parser for HTML documents

Source

pub fn parse_file(&self, filename: &str) -> Result<Document, XmlParseError>

Parses the XML/HTML file filename to generate a new Document

Source

pub fn parse_file_with_options( &self, filename: &str, parser_options: ParserOptions<'_>, ) -> Result<Document, XmlParseError>

Parses the XML/HTML file filename with a manually-specified parser-options to generate a new Document

Source

pub fn parse_string<Bytes: AsRef<[u8]>>( &self, input: Bytes, ) -> Result<Document, XmlParseError>

Parses the XML/HTML bytes input to generate a new Document

Source

pub fn parse_string_with_options<Bytes: AsRef<[u8]>>( &self, input: Bytes, parser_options: ParserOptions<'_>, ) -> Result<Document, XmlParseError>

Parses the XML/HTML bytes input with a manually-specified parser-options to generate a new Document

Source

pub fn is_well_formed_html<Bytes: AsRef<[u8]>>(&self, input: Bytes) -> bool

Checks a string for well-formedness.

Source

pub fn is_well_formed_html_with_encoding<Bytes: AsRef<[u8]>>( &self, input: Bytes, encoding: Option<&str>, ) -> bool

Checks a string for well-formedness with manually-specified encoding. IMPORTANT: This function is currently implemented in a HACKY way, to ignore invalid errors for HTML5 elements (such as ) this means you should NEVER USE IT WHILE THREADING, it is CERTAIN TO BREAK

Help is welcome in implementing it correctly.

Trait Implementations§

Source§

impl Default for Parser

Source§

fn default() -> Self

Create a parser for XML documents

Auto Trait Implementations§

§

impl Freeze for Parser

§

impl RefUnwindSafe for Parser

§

impl Send for Parser

§

impl Sync for Parser

§

impl Unpin for Parser

§

impl UnwindSafe for Parser

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.