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

Adapters for AsyncRead and Stream? #35

Open
davidpdrsn opened this issue Jan 30, 2021 · 2 comments
Open

Adapters for AsyncRead and Stream? #35

davidpdrsn opened this issue Jan 30, 2021 · 2 comments

Comments

@davidpdrsn
Copy link
Member

In tower-http we have an adapter that makes an AsyncRead into a Body https://github.com/tower-rs/tower-http/blob/serve-file/tower-http/src/serve_file.rs#L107. Is that something you'd be interested in upstreaming to http-body? Might be useful for others.

Adapters for Stream<Item = Bytes> and Stream<Item = Vec<u8>> might also be nice.

If you're interested I can submit a PR.

@tesaguri
Copy link
Contributor

I think it is more useful for http-body to have something like hyper::Body::wrap_stream, with which you can trivially wrap tokio_util::io::ReaderStream to convert an impl AsyncRead to an impl Body.

@davidpdrsn
Copy link
Member Author

Yeah thats probably useful as well. However a straight AsyncRead to Body adapter is useful for example with tokio::fs::File.

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 a pull request may close this issue.

2 participants