Struct stringsext::scanner::ScannerState [−][src]
pub struct ScannerState {
pub mission: &'static Mission,
pub decoder: Decoder,
pub last_scan_run_leftover: String,
pub last_run_str_was_printed_and_is_maybe_cut_str: bool,
pub consumed_bytes: u64,
}
Expand description
Some object that holds the state of the scanner::FindingCollection::scan()
function allowing
to process the input stream in batches.
Fields
mission: &'static Mission
It contains all (static) information needed to parametrize the decoding and the
filtering performed by scanner::FindingCollection::scan()
decoder: Decoder
The decoder may hold in its internal state, among other things, some bytes of output, when a multibyte encoder was cut at the end of a buffer.
last_scan_run_leftover: String
For short strings (< chars_min_nb
) at the very end of the buffer, we
can not decide immediately, if they have to be printed or not, because we
can not peek()
into what is coming in the next chunk. Maybe the
beginning of the next chunk completes this short string from the previous
run, and both together are long enough (>= chars_min_nb
) to be printed?
last_run_str_was_printed_and_is_maybe_cut_str: bool
The last printed string touched the right boundary of the buffer, so it
might cut and to be continued with the first string in the next run.
last_run_str_was_printed_and_is_maybe_cut_str
remembers this fact and
advises the filter to check if the first string of the next run touches
the left boundary of the buffer. If yes, this string will be printed,
whatever length it has.
consumed_bytes: u64
This an absolute byte counter counting bytes of the input stream. The
value will be update after a FindingCollection::scan()
run to point to the first not
scanned byte in the input stream.