Instead of having a receive_message() method on the client, have the subscribe_* methods return a type holding a mut reference to the client, and implementing the Stream trait from the futures crate. Usage
let sub = client.subscribe_to_topic(...).await;
loop {
if let Ok(message) = sub.next().await {
// Process message
}
}
Then when sub goes out of scope, the client can be reused.
Instead of having a receive_message() method on the client, have the subscribe_* methods return a type holding a mut reference to the client, and implementing the Stream trait from the futures crate. Usage
Then when sub goes out of scope, the client can be reused.