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

implement AsyncSeek for StreamReader<R: AsyncRead + AsyncSeek + Unpin> #500

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

tgcGlaDius
Copy link

Simple porting of the sync Seek implementation of StreamReader to use async calls. The implementation adds a new field named seek_state to the StreamReader when the async feature is enabled. This field acts as a state machine state for the async poll_seek call.

One thing of note is that the current implementation puts the StreamReader in a "bad" state while a seek is being performed, after the seek is performed, then the reader is back into a good working state. This could lead to scenarios where a seek future has been created and polled a few times, but then for some reason gets dropped, if that happens then the stream is left in a non-working bad state. I dont think this really needs fixing as i would expect performing a "half" seek would lead to unexpected behaviour anyway, but it is something that should be documented

I have also copied over the sync seeking tests to use async seeks and reads instead. This is the only real testing of my implementation that i have performed, so if more tests are in order then give a heads up and i will try to implement it

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.

None yet

1 participant