[−][src]Module async_zmq::xsubscribe
XSUB socket module of Pub-Sub pattern in ZMQ
Use xsubscribe
function to instantiate a XSUB socket 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::xsubscribe("tcp://127.0.0.1:5555")?.bind()?; // 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
XSubscribe | The async wrapper of ZMQ socket with XSUB type |
Functions
xsubscribe | Create a ZMQ socket with XSUB type |