Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow usage without Seek: RevReader approach #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

florian1345
Copy link

Implemented my proposal to resolve #12 .

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 (🔬 Tracking issue for generic associated types (GAT) rust-lang/rust#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 RustAudio#12 .
Copy link
Member

@est31 est31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for the most part.

src/reading.rs Outdated Show resolved Hide resolved
src/reading.rs Outdated Show resolved Hide resolved
src/reading.rs Outdated Show resolved Hide resolved
src/reading.rs Show resolved Hide resolved
src/reading.rs Show resolved Hide resolved
src/reading.rs Outdated Show resolved Hide resolved
src/reading.rs Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove the requirement for std::io::Seek for PacketReader etc.
2 participants