I have the following code where I am able to get and print the topic and payload from a message:
let callback = |msg: rumqtt::Message| {
let t = &msg.topic.as_str();
let s = String::from_utf8_lossy(&msg.payload);
println!("Topic = {}", t);
println!("Received payload: {}", s);
};
let mq_cbs = MqttCallback::new().on_message(callback);
The question is how can I get the topic and payload outside of the closure?