Minimal async decoder support#46
Draft
rklaehn wants to merge 10 commits into
Draft
Conversation
this is so DecoderShared can be used from async decoders
for now just for the Decoder in inline and outboard mode, not yet for the SliceDecoder.
rklaehn
commented
Jan 27, 2023
| } | ||
|
|
||
| #[derive(Clone, Debug)] | ||
| pub struct AsyncDecoder<T: AsyncRead + Unpin, O: AsyncRead + Unpin> { |
Author
There was a problem hiding this comment.
It would also be possible to have the Decoder support both async and sync, but the ergonomics of that is really bad. I tried it. So I went with this tiny wrapper instead.
This requires some seek logic, but no actual seeking in the underlying inputs
Author
|
I looked into what it would take to support seek. I think once you do that you can no longer share DecoderShared with the sync version, since you need some state enum... Goddamn async... |
just give the state a case Done so we can implement take
we don't have to do this anymore now that we properly track state
1639453 to
d44f5c7
Compare
also update comments
13825f7 to
c1f7c9c
Compare
This can always succeed, because the SliceDecoder will never implement Seek
009f74e to
2329a8f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is an attempt to split #44 into more manageable parts.
Adds very limited async support. For now just
tokio::io::AsyncReadforDecoderandSliceDecoder.Tries to share the maximum amount possible with
DecoderShared.If the code structure and general approach is OK, it would be easy to also add support for
futures::io::AsyncRead.Seek support is a bit more complex, so probably best done in a subsequent PR.