implement AsyncSeek for StreamReader<R: AsyncRead + AsyncSeek + Unpin> #500
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Simple porting of the sync
Seek
implementation ofStreamReader
to use async calls. The implementation adds a new field namedseek_state
to theStreamReader
when theasync
feature is enabled. This field acts as a state machine state for the asyncpoll_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 documentedI 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