pub trait StanzaHandler: Send + Sync {
// Required methods
fn tag(&self) -> &'static str;
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
client: Arc<Client>,
node: &'life1 Node,
cancelled: &'life2 mut bool,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}Expand description
Trait for handling specific types of XML stanzas received from the WhatsApp server.
Each handler is responsible for processing a specific top-level XML tag (e.g., “message”, “iq”, “receipt”). This pattern allows for better separation of concerns and makes it easier to add new stanza types without modifying the core client dispatch logic.
Required Methods§
Sourcefn tag(&self) -> &'static str
fn tag(&self) -> &'static str
Returns the XML tag this handler is responsible for (e.g., “message”, “iq”).
Sourcefn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
client: Arc<Client>,
node: &'life1 Node,
cancelled: &'life2 mut bool,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
client: Arc<Client>,
node: &'life1 Node,
cancelled: &'life2 mut bool,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Asynchronously handle the incoming node.
§Arguments
client- Arc reference to the client instancenode- The XML node to processcancelled- If set totrue, prevents the deferred ack from being sent
§Returns
Returns true if the node was successfully handled, false if it should be
processed by other handlers or logged as unhandled.