use std::{collections::HashMap, time::Duration};
use nt_client::{Client, publish::UpdateProps, topic::Properties};
use serde_json::json;
#[tokio::main]
async fn main() {
let client = Client::new(Default::default());
client.connect_setup(setup).await.unwrap()
}
fn setup(client: &Client) {
let topic = client.topic("/mytopic");
tokio::spawn(async move {
let mut extra_props = HashMap::new();
extra_props.insert("custom".to_string(), json!("something"));
let mut publisher = topic.publish::<String>(Properties { cached: Some(true), extra: extra_props, ..Default::default() }).await.unwrap();
tokio::time::sleep(Duration::from_secs(1)).await;
let updated = UpdateProps::new()
.set_persistent(true)
.delete("custom".to_string());
publisher.update_props(updated).await.unwrap();
});
}