blockwise_reader
Reading and pre-parsing of large files or streams.
The BlockWiseReader allows it to parse headers of files or streams where you not exactly know how many bytes you need to read to be able to continue to parse.
So what you need is an educated guess for the amount you want to read.
The main task here is to avoid to read all the data before you begin to parse something.
Because there are cases where it is just too much.
For any token or sequence of tokens you want to find you can decide how many bytes you want to read ahead. It can also be all of it if you are certain.
As soon as you have identified all parts you need, you can then continue to parse your gathered bytes by more advanced parsers like for instance nom, combine, chumsky or pest.
use StringReader;
use BlockWiseReader;
let sr = new;
let mut bwr = new;
assert!;
assert!;
assert!;
let pos = bwr.pos_get;
assert!;
assert_eq!;
It is also possible to search blockwise to a matching fixed byte slice. But there is the risk that this byte slice never will appear in the stream.
use StringReader;
use BlockWiseReader;
use FindPos;
let sr = new;
let mut bwr = new;
// reads repeatedly 100 byte blocks and stops if match appears
assert!;
assert_eq!;