Function subscribe_async

Source
pub fn subscribe_async(endpoints: &[&str]) -> Result<MessageStream, Error>
Available on crate feature async only.
Expand description

Subscribes to multiple ZMQ endpoints and returns a stream that produces Messages.

Examples found in repository?
examples/subscribe_async.rs (line 6)
5fn main() {
6    let mut stream = subscribe_async(&["tcp://127.0.0.1:28332"]).unwrap();
7
8    // This is a small example to demonstrate subscribe_single_async, it is okay here to use
9    // block_on, but not in production environments as this defeats the purpose of async.
10    block_on(async {
11        while let Some(msg) = stream.next().await {
12            match msg {
13                Ok(msg) => println!("Received message: {msg}"),
14                Err(err) => println!("Error receiving message: {err}"),
15            }
16        }
17    });
18}