Skip to content

Implement the futures Stream trait for subscriptions #10

@lulf

Description

@lulf

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions