whatsapp_rust/handlers/
iq.rs

1use super::traits::StanzaHandler;
2use crate::client::Client;
3use async_trait::async_trait;
4use log::warn;
5use std::sync::Arc;
6use wacore::xml::DisplayableNode;
7use wacore_binary::node::Node;
8
9/// Handler for `<iq>` (Info/Query) stanzas.
10///
11/// Processes various query types including:
12/// - Ping/pong exchanges
13/// - Pairing requests
14/// - Feature queries
15/// - Settings updates
16#[derive(Default)]
17pub struct IqHandler;
18
19impl IqHandler {
20    pub fn new() -> Self {
21        Self
22    }
23}
24
25#[async_trait]
26impl StanzaHandler for IqHandler {
27    fn tag(&self) -> &'static str {
28        "iq"
29    }
30
31    async fn handle(&self, client: Arc<Client>, node: &Node, _cancelled: &mut bool) -> bool {
32        if !client.handle_iq(node).await {
33            warn!(target: "Client", "Received unhandled IQ: {}", DisplayableNode(node));
34        }
35        true
36    }
37}