whatsapp_rust/handlers/
unimplemented.rs1use super::traits::StanzaHandler;
2use crate::client::Client;
3use async_trait::async_trait;
4use std::sync::Arc;
5use wacore_binary::node::Node;
6
7pub struct UnimplementedHandler {
16 tags: Vec<&'static str>,
17}
18
19impl UnimplementedHandler {
20 pub fn new(tags: Vec<&'static str>) -> Self {
21 Self { tags }
22 }
23
24 pub fn for_call() -> Self {
25 Self::new(vec!["call"])
26 }
27
28 pub fn for_presence() -> Self {
29 Self::new(vec!["presence"])
30 }
31
32 pub fn for_chatstate() -> Self {
33 Self::new(vec!["chatstate"])
34 }
35}
36
37#[async_trait]
38impl StanzaHandler for UnimplementedHandler {
39 fn tag(&self) -> &'static str {
40 if self.tags.len() == 1 {
43 self.tags[0]
44 } else {
45 panic!("UnimplementedHandler with multiple tags should be registered individually")
46 }
47 }
48
49 async fn handle(&self, client: Arc<Client>, node: &Node, _cancelled: &mut bool) -> bool {
50 client.handle_unimplemented(&node.tag).await;
51 true
52 }
53}