I'm trying to implement poll_next for for a struct that communicates over a web socket (tokio_tungstenite).
The challenge I have is, to produce one message for my app, I need to consume two or more messages over the websocket.
For the first web socket message I can simply call poll_next on the web socket, and if it doesn't return an item, return pending.
What I can't figure out is how to wait for the following messages, i.e. my code may have to make several calls to the web socket poll_next before I can return a message.
It would be awesome if anyone has done this or could point me to some code that does something similar.
Writing poll_* methods manually can in some cases be very difficult, and I definitely recommend going for the async-stream crate unless you have good reasons for avoiding it.
If you are still interested in poll_* methods, there is a rough introduction to the internals of async/await in this chapter, along with a Stream example in the stream chapter.