Expand description
An encapsulation of BufReader
’s buffer management logic.
This module factors out the basic functionality of BufReader
in order to protect two core
invariants:
filled
bytes ofbuf
are always initializedpos
is always <=filled
Since this module encapsulates the buffer management logic, we can ensure that the rangepos..filled
is always a valid index into the initialized region of the buffer. This means that user code which wants to do reads from aBufReader
viabuffer
+consume
can do so without encountering any runtime bounds checks.