Skip to main content

subscribe

Function subscribe 

Source
pub async fn subscribe<F, R>(topic: &str, consumer: F)
where F: Fn(Message) -> R + Send + Sync + 'static, R: Future<Output = ()> + Send + Sync + 'static,
Expand description

Subscribes to messages on a specific topic.

§Arguments

  • topic - Message topic
  • consumer - A callback function to process incoming messages from the topic.

§Examples

zimq::subscribe("user", user_consume).await;

async fn user_consume(msg: Message) {
   // TODO
}