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
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