pub struct Scanner<T, R>{ /* private fields */ }std only.Expand description
A Scanner is a forward lookahead struct that scans through an stream of data looking for the indicated tokens.
The amount of possible forward lookahead is specified by the internal buffer
size of the BufReader
Implementations§
Source§impl<T: Read + Sized, R: Clone> Scanner<T, R>
impl<T: Read + Sized, R: Clone> Scanner<T, R>
Sourcepub fn new(input: T, delimiters: &[Token<R>]) -> Self
pub fn new(input: T, delimiters: &[Token<R>]) -> Self
Creates a scanner with the default buffer capacity, 8KB
Sourcepub fn with_max_lookahead(
input: T,
max_buffer: usize,
delimiters: &[Token<R>],
) -> Self
pub fn with_max_lookahead( input: T, max_buffer: usize, delimiters: &[Token<R>], ) -> Self
Creates a scanner with the specified buffer capacity
Sourcepub fn scan_until_next(&mut self) -> Result<FoundToken<'_, R>, Error>
pub fn scan_until_next(&mut self) -> Result<FoundToken<'_, R>, Error>
Scans through the buffer, looking for the specified token. Returns the
number of bytes in the stream needed to position the cursor to JUST BEFORE
the token. I.E., after calling read_exact(scan_until()), the next
call to read() will return the token itself.
Returns Ok(N) if it found the token in the input stream, or hit the end of the buffer without finding the token
Returns Ok(None) if there are no additional characters to read in the buffer - we’ve hit EOF.
Returns Err(e) if there’s an error reading from the underlying stream