eclipse / paho.mqtt.rust

paho.mqtt.rust
Other
511 stars 102 forks source link

Bounded synchronous channel for consumer. #196

Open fpagliughi opened 1 year ago

fpagliughi commented 1 year ago

PR #191 added the choice of a bounded or unbounded channel in an async/await client. We should do the same thing for the sync channel created in AsyncClient::start_consuming().

But as this would be a breaking change for the function signature, it needs to wait for the next major update.

I assume it would be implemented in the same way as the async stream, something like:

pub fn start_consuming<L>(&mut self, buffer_lim: L) -> Receiver<Option<Message>>
where
    L: Into<Option<usize>>,
{
    let (tx, rx) = match buffer_lim.into() {
        None => channel::unbounded(),
        Some(lim) => channel::bounded(lim),
    };
    ...