Trait html5tokenizer::reader::Reader
source · pub trait Reader {
type Error: Error;
// Required methods
fn read_char(&mut self) -> Result<Option<char>, Self::Error>;
fn try_read_string(
&mut self,
s: &str,
case_sensitive: bool
) -> Result<bool, Self::Error>;
fn len_of_char_in_current_encoding(&self, c: char) -> usize;
}
Expand description
An object that provides characters to the tokenizer.
Patches are welcome for providing an efficient implementation over async streams, iterators, files, etc, as long as any dependencies come behind featureflags.
Required Associated Types§
Required Methods§
sourcefn read_char(&mut self) -> Result<Option<char>, Self::Error>
fn read_char(&mut self) -> Result<Option<char>, Self::Error>
Return a new character from the input stream.
The input stream does not have to be preprocessed in any way, it can contain standalone surrogates and have inconsistent newlines.
sourcefn try_read_string(
&mut self,
s: &str,
case_sensitive: bool
) -> Result<bool, Self::Error>
fn try_read_string( &mut self, s: &str, case_sensitive: bool ) -> Result<bool, Self::Error>
Attempt to read an entire string at once, either case-insensitively or not.
case_sensitive=false
means that characters of the input stream should be compared while
ignoring ASCII-casing.
It can be assumed that this function is never called with a string that contains \r
or
\n
.
If the next characters equal to s
, this function consumes the respective characters from
the input stream and returns true
. If not, it does nothing and returns false
.
sourcefn len_of_char_in_current_encoding(&self, c: char) -> usize
fn len_of_char_in_current_encoding(&self, c: char) -> usize
Returns the number of bytes that the given character takes up in the current character encoding.