Skip to content

Commit

Permalink
AsyncClient::get_stream(): change buffer_sz parameter type to Option<…
Browse files Browse the repository at this point in the history
…usize>

Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
  • Loading branch information
fbrouille committed Mar 1, 2023
1 parent a2f9e5e commit 8375060
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/async_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1087,14 +1087,18 @@ 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<Option<Message>> {
pub fn get_stream(&mut self, buffer_sz: Option<usize>) -> AsyncReceiver<Option<Message>> {
let (tx, rx) = match buffer_sz {
0 => async_channel::unbounded(),
cap => async_channel::bounded(cap),
None => async_channel::unbounded(),
Some(capacity) => async_channel::bounded(capacity),
};

// Make sure at least the low-level connection_lost handler is in
Expand Down

0 comments on commit 8375060

Please sign in to comment.