pub struct Reader<'r> {
pub index: usize,
pub line: usize,
pub column: usize,
/* private fields */
}Fields§
§index: usize§line: usizelocation feature required
Line of current parsing point
column: usizelocation feature required
Column of current parsing point
Implementations§
Source§impl<'r> Reader<'r>
impl<'r> Reader<'r>
pub const fn new(buf: &'r [u8]) -> Self
pub fn remaining(&self) -> &[u8]
Sourcepub fn advance_by(&mut self, max: usize)
pub fn advance_by(&mut self, max: usize)
Advance by max bytes (or, if remaining bytes is shorter than max, read all remaining bytes)
Sourcepub fn unwind_by(&mut self, max: usize)
pub fn unwind_by(&mut self, max: usize)
Unwind the parsing point by max bytes (or, if already-read bytes is shorter than max, rewind all)
When "location" feature is activated, this may be less performant for some extensive input
Sourcepub fn skip_while(&mut self, condition: impl Fn(&u8) -> bool)
pub fn skip_while(&mut self, condition: impl Fn(&u8) -> bool)
Skip next byte while condition holds on it
Sourcepub fn skip_whitespace(&mut self)
pub fn skip_whitespace(&mut self)
skip_while(u8::is_ascii_whitespace)
Sourcepub fn read_while(&mut self, condition: impl Fn(&u8) -> bool) -> &'r [u8]
pub fn read_while(&mut self, condition: impl Fn(&u8) -> bool) -> &'r [u8]
Read next byte while the condition holds on it
Sourcepub fn read_until(&mut self, pattern: impl AsRef<[u8]>) -> &'r [u8]
pub fn read_until(&mut self, pattern: impl AsRef<[u8]>) -> &'r [u8]
Read through until the pattern comes in front of reader.
Sourcepub fn next(&mut self) -> Option<u8>
pub fn next(&mut self) -> Option<u8>
Read next byte, or return None if the remaining bytes is empty
Sourcepub fn next_if(&mut self, condition: impl Fn(&u8) -> bool) -> Option<u8>
pub fn next_if(&mut self, condition: impl Fn(&u8) -> bool) -> Option<u8>
Read next byte if the condition holds on it
Sourcepub fn peek3(&self) -> Option<&u8>
pub fn peek3(&self) -> Option<&u8>
Peek next byte of next byte of next byte (without consuming)
Source§impl<'r> Reader<'r>
impl<'r> Reader<'r>
Sourcepub fn read_camel(&mut self) -> Option<&'r str>
pub fn read_camel(&mut self) -> Option<&'r str>
text feature required
Read a camelCase word like helloWorld, userID, … as &str if found
Sourcepub fn read_snake(&mut self) -> Option<&'r str>
pub fn read_snake(&mut self) -> Option<&'r str>
text feature required
Read a snake_case word like hello_world, user_id, … as &str if found
Sourcepub fn read_kebab(&mut self) -> Option<&'r str>
pub fn read_kebab(&mut self) -> Option<&'r str>
text feature required
Read a kebeb-case word like hello-world, Content-Type, … as &str if found
Sourcepub fn read_quoted_by(&mut self, left: u8, right: u8) -> Option<&'r [u8]>
pub fn read_quoted_by(&mut self, left: u8, right: u8) -> Option<&'r [u8]>
text feature required
Read all bytes enclosed between left and right, then consume left, the bytes and right, and return the bytes.
Or, returns None if left or right is not found in remaining bytes.