Instead of Seek, the (non-seeking) functionality of the PacketReader now requires a new trait RevRead which allows making a single reversible read operation. This is blanket-implemented for all types implementing Read + Seek, so business as usual is possible. Beyond that, I added the RevReader which implements RevRead solely on the basis of Read. This allows usage of the PacketReader with underlying readers that do not implement Seek.
The tests seem to pass (on my machine), but I have not yet tried to apply this to an OGG file where seeking is actually necessary. Do the tests cover that scenario?
Potential Drawbacks
The interface of some public functions has changed.
Currently, the RevRead trait carries an annoying lifetime that is required to return references to internal state of the reader. This could probably be resolved with generic associated types (https://github.com/rust-lang/rust/issues/44265).
Potentially slightly slower performance with general reads when using the RevReader. I have not run any benchmarks yet, if that is necessary, please request.
Implemented my proposal to resolve #12 .
Instead of
Seek
, the (non-seeking) functionality of thePacketReader
now requires a new traitRevRead
which allows making a single reversible read operation. This is blanket-implemented for all types implementingRead + Seek
, so business as usual is possible. Beyond that, I added theRevReader
which implementsRevRead
solely on the basis ofRead
. This allows usage of thePacketReader
with underlying readers that do not implementSeek
.The tests seem to pass (on my machine), but I have not yet tried to apply this to an OGG file where seeking is actually necessary. Do the tests cover that scenario?
Potential Drawbacks
RevRead
trait carries an annoying lifetime that is required to return references to internal state of the reader. This could probably be resolved with generic associated types (https://github.com/rust-lang/rust/issues/44265).RevReader
. I have not run any benchmarks yet, if that is necessary, please request.