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

impl AsyncBufRead for Decoder #289

Open
DrewMcArthur opened this issue Jul 30, 2024 · 1 comment
Open

impl AsyncBufRead for Decoder #289

DrewMcArthur opened this issue Jul 30, 2024 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@DrewMcArthur
Copy link

Hi! So I've got a stream: impl AsyncBufRead, which may or may not be gzipped. I'm trying to return that stream in a function whose return type is Result<impl AsyncBufRead, Error>, but running into the issue where the GzipDecoder is AsyncRead, but not AsyncBufRead. Since the inner reader it pulls from is AsyncBufRead, is there any reason why the decoder itself can't be AsyncBufRead?

Or, am I misreading the docs, and I should just be calling into_inner()? the way I read it currently, this returns the original stream though, not the decoded version.

If it's easier, I just need this for the GzipDecoder, but I assume this level would be generic across all the Decoders.

@robjtede robjtede added the enhancement New feature or request label Jul 31, 2024
@DrewMcArthur
Copy link
Author

update: I was able to update my function to return a Box<dyn AsyncRead>, which covers both the GZipped case (returning a GzipDecoder: AsyncRead) and the plain filestream from S3 (returning an impl AsyncBufRead, which also is AsyncRead). Since my parsing function downstream just needs a Stream<Item=Bytes>, that's all I needed.

I'm still very curious what it would take to implement AsyncBufRead for the Decoder. I tried messing around with it a bit last night, but I'm too unfamiliar with Pins and all of that.

@robjtede robjtede added the good first issue Good for newcomers label Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants