diff --git a/src/async_client.rs b/src/async_client.rs index e8b34e2..6d7bef7 100644 --- a/src/async_client.rs +++ b/src/async_client.rs @@ -1108,12 +1108,19 @@ impl AsyncClient { /// gets disconnected, it will insert `None` into the channel to signal /// the app about the disconnect. /// + /// The stream will rely on a bounded channel with the given buffer + /// capacity if 'buffer_sz' is 'Some' or will rely on an unbounded channel + /// if 'buffer_sz' is 'None'. + /// /// It's a best practice to open the stream _before_ connecting to the /// server. When using persistent (non-clean) sessions, messages could /// arriving as soon as the connection is made - even before the /// connect() call returns. - pub fn get_stream(&mut self, buffer_sz: usize) -> AsyncReceiver> { - let (tx, rx) = async_channel::bounded(buffer_sz); + pub fn get_stream(&mut self, buffer_sz: Option) -> AsyncReceiver> { + let (tx, rx) = match buffer_sz { + None => async_channel::unbounded(), + Some(capacity) => async_channel::bounded(capacity), + }; // Make sure at least the low-level connection lost handlers are in // place to notify us when the connection is lost (sends a 'None' to