pub async fn unsubscribe(self) -> Result<()> {
        let topics = {
            let mqtt_topic_handlers = &self.client.mqtt_topic_handlers;
            let mqtt_topic_handlers = mqtt_topic_handlers.read().await;
            if self.topics.is_empty() {
                mqtt_topic_handlers.keys().cloned().collect()
            } else {
                self.topics
            }
        };

        if let Some(client) = &mut self.client.mqtt_client {
            for topic in topics.iter() {
                client.unsubscribe(&topic.0).await?;
            }
        }

        let empty_topic_handlers = {
            let mqtt_topic_handlers = &self.client.mqtt_topic_handlers;
            let mut mqtt_topic_handlers = mqtt_topic_handlers.write().await;
            for topic in topics {
                mqtt_topic_handlers.remove(&topic);
            }
            mqtt_topic_handlers.is_empty()
        };

        if self.client.broker_options.automatic_disconnect && empty_topic_handlers {
            MqttManager::new(self.client).disconnect().await?;
        }

        Ok(())
    }
/// Unsubscribe from the given topics.
/// If no topics were provided, the function will unsubscribe from every subscribed topic.
Unsubscribe from the given topics.
If no topics were provided, the function will unsubscribe from every subscribed topic.
Unsubscribe from the given topics . If no topics were provided the function will unsubscribe from every subscribed topic .
pub async fn unsubscribe(self) -> Result<()> {
        let topics = {
            let mqtt_topic_handlers = &self.client.mqtt_topic_handlers;
            let mqtt_topic_handlers = mqtt_topic_handlers.read().await;
            if self.topics.is_empty() {
                mqtt_topic_handlers.keys().cloned().collect()
            } else {
                self.topics
            }
        };
        if let Some(client) = &mut self.client.mqtt_client {
            for topic in topics.iter() {
                client.unsubscribe(&topic.0).await?;
            }
        }
        let empty_topic_handlers = {
            let mqtt_topic_handlers = &self.client.mqtt_topic_handlers;
            let mut mqtt_topic_handlers = mqtt_topic_handlers.write().await;
            for topic in topics {
                mqtt_topic_handlers.remove(&topic);
            }
            mqtt_topic_handlers.is_empty()
        };
        if self.client.broker_options.automatic_disconnect && empty_topic_handlers {
            MqttManager::new(self.client).disconnect().await?;
        }
        Ok(())
    }
pub async fn unsubscribe ( self ) -> Result < ( ) > { let topics = { let mqtt_topic_handlers = & self . client . mqtt_topic_handlers ; let mqtt_topic_handlers = mqtt_topic_handlers . read ( ) . await ; if self . topics . is_empty ( ) { mqtt_topic_handlers . keys ( ) . cloned ( ) . collect ( ) } else { self . topics } } ; if let Some ( client ) = & mut self . client . mqtt_client { for topic in topics . iter ( ) { client . unsubscribe ( & topic . 0 ) . await ? ; } } let empty_topic_handlers = { let mqtt_topic_handlers = & self . client . mqtt_topic_handlers ; let mut mqtt_topic_handlers = mqtt_topic_handlers . write ( ) . await ; for topic in topics { mqtt_topic_handlers . remove ( & topic ) ; } mqtt_topic_handlers . is_empty ( ) } ; if self . client . broker_options . automatic_disconnect && empty_topic_handlers { MqttManager :: new ( self . client ) . disconnect ( ) . await ? ; } Ok ( ( ) ) }
Unsubscribe from the given topics.
Unsubscribe from the given topics .
self
self