[−][src]Module async_zmq::subscribe
SUB socket module of Pub-Sub pattern in ZMQ
Use subscribe
function to instantiate a subscriber and the you will be able to use methods from Stream
/StreamExt
trait.
Example
use async_zmq::{Result, StreamExt}; #[async_std::main] async fn main() -> Result<()> { let mut zmq = async_zmq::subscribe("tcp://127.0.0.1:5555")?.connect()?; // Subscribe the topic you want to listen. // Users can subscribe multiple topics and even unsubscribe later. zmq.set_subscribe("topic")?; while let Some(msg) = zmq.next().await { // Received message is a type of Result<MessageBuf> let msg = msg?; println!("{:?}", msg.iter()); } Ok(()) }
Structs
Subscribe | The async wrapper of ZMQ socket with SUB type |
Functions
subscribe | Create a ZMQ socket with SUB type |