reading-liner
Reading and convert offset and line-column location.
A Stream reader which can convert between byte offset and line-column numbers.
Support any type which implements io::Read.
The whole design is based on an Index,
which is composed of line information to convert between byte offsets and line-column locations.
One perticular usage is to use the Stream as a builder of Index or
you can also use it when lazily reading and convert locations at the same time.
This lib should be used at low-level abstraction.
Documentation
The API is documented: https://docs.rs/reading-liner
Core methods
Immutable queries (best practice)
- locate line-column location from byte offset:
Query::locate(&self, Offset) -> Option<line_column::ZeroBased>
- encode offset from line-column location
Query::encode(&self, line_column::ZeroBased) -> Option<Offset>
Mutable queries
The names are the same with immutable ones, but be careful since these mutable queries may read bytes implicitly.
- locate line-column location from byte offset:
Stream::locate(&mut self, Offset) -> io::Result<line_column::ZeroBased>
- encode offset from line-column location
Stream::encode(&mut self, line_column::ZeroBased) -> io::Result<Offset>
Example
use ;
use Read;
use ;