aatxe / irc

the irc crate – usable, async IRC for Rust
Mozilla Public License 2.0
530 stars 97 forks source link

Add the ability to check for messages from a Server without blocking indefinitely #65

Closed ovibos closed 7 years ago

ovibos commented 7 years ago

Currently the only way to check for messages on a Server is to get an Iterator from iter() and then call next() on it, which blocks forever. It would be nice if there was an alternate way to poll for new messages which allowed for a timeout, or some other method of preventing indefinite blocking.

glandium commented 7 years ago

Even nicer would be an API using futures.

FreeFull commented 7 years ago

In my IRC client, I've settled for having the iterator in a separate thread, and sending every item through a channel. Futures would be nice to have at some point, but this works well for now.

aatxe commented 7 years ago

I'm going to start experimenting with a new version using Tokio. This should address this issue and #62 concurrently.

aatxe commented 7 years ago

With the new 0.12.0 release, we use tokio internally and present two methods of processing messages: a synchronous one (for_each_incoming) that behaves much like the old iterator approach and an asynchronous one (a standard futures::Stream) which you can use however you'd like. I'm interested in hearing feedback about use of the latter approach.