Skip to content

Tokio server/client example? #109

Open
@bspeice

Description

@bspeice

Question up front: is it possible to use this crate with tokio?

I'm interested in building a library for using the Spotify API; the existing rspotify seems to be tied to tokio through its dependence on reqwest. I'd like this library to be executor-independent, and looking through some recent discussions led me to this crate in particular.

I was initially a bit disappointed to see that there was no client_tokio example or something similar given that it's been claimed that async-h1 doesn't care about the server it's running with. After trying to make such an example myself, I seemed to run into a bigger issue: because tokio's TcpStream doesn't implement futures::io::AsyncRead (it implements tokio::io::AsyncRead instead), I think the orphan rule prevents async-h1 from working with tokio.

Am I crazy, or is it currently impossible to use this crate with tokio?


EDIT: After further research, it appears like this can be accomplished using a compatibility wrapper, there's an example here: https://github.com/Nemo157/futures-tokio-compat/blob/master/src/lib.rs (which seems to have an additional benefit of not allocating the Pin, meaning this should be zero-cost?). I'm planning to keep working on it, if I finish up an example, is that something this project is interested in having added to the examples?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions