diff --git a/src/features/chatstate.rs b/src/features/chatstate.rs index daee3de13..ee22e7403 100644 --- a/src/features/chatstate.rs +++ b/src/features/chatstate.rs @@ -8,6 +8,7 @@ use wacore_binary::jid::Jid; /// Chat state type for typing indicators. #[derive(Debug, Clone, Copy, PartialEq, Eq, StringEnum)] +#[non_exhaustive] pub enum ChatStateType { #[str = "composing"] Composing, diff --git a/src/features/community.rs b/src/features/community.rs index e79fbb988..696444093 100644 --- a/src/features/community.rs +++ b/src/features/community.rs @@ -20,6 +20,7 @@ use wacore_binary::jid::Jid; /// Classification of a group within the community hierarchy. #[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] pub enum GroupType { /// Regular standalone group (not part of a community). Default, @@ -34,7 +35,7 @@ pub enum GroupType { } /// Options for creating a new community. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct CreateCommunityOptions { pub name: String, pub description: Option, @@ -59,14 +60,14 @@ impl CreateCommunityOptions { } /// Result of creating a community. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct CreateCommunityResult { /// JID of the created community parent group. pub gid: Jid, } /// A subgroup within a community. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct CommunitySubgroup { pub id: Jid, pub subject: String, @@ -76,14 +77,14 @@ pub struct CommunitySubgroup { } /// Result of linking subgroups to a community. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct LinkSubgroupsResult { pub linked_jids: Vec, pub failed_groups: Vec<(Jid, u32)>, } /// Result of unlinking subgroups from a community. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct UnlinkSubgroupsResult { pub unlinked_jids: Vec, pub failed_groups: Vec<(Jid, u32)>, diff --git a/src/features/groups.rs b/src/features/groups.rs index 192f31156..ac94fde59 100644 --- a/src/features/groups.rs +++ b/src/features/groups.rs @@ -18,7 +18,7 @@ pub use wacore::iq::groups::{ ParticipantChangeResponse, }; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct GroupMetadata { pub id: Jid, pub subject: String, @@ -62,7 +62,7 @@ pub struct GroupMetadata { pub allow_non_admin_sub_group_creation: bool, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct GroupParticipant { pub jid: Jid, pub phone_number: Option, @@ -108,7 +108,7 @@ impl From for GroupMetadata { } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct CreateGroupResult { pub gid: Jid, } diff --git a/src/features/newsletter.rs b/src/features/newsletter.rs index 09e270ac7..80055f662 100644 --- a/src/features/newsletter.rs +++ b/src/features/newsletter.rs @@ -20,6 +20,7 @@ use waproto::whatsapp as wa; // Types #[derive(Debug, Clone, PartialEq, Eq, StringEnum)] +#[non_exhaustive] pub enum NewsletterMessageType { #[str = "text"] Text, @@ -40,14 +41,16 @@ pub enum NewsletterMessageType { } /// Newsletter verification status. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] +#[non_exhaustive] pub enum NewsletterVerification { Verified, Unverified, } /// Newsletter state. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] +#[non_exhaustive] pub enum NewsletterState { Active, Suspended, @@ -55,7 +58,8 @@ pub enum NewsletterState { } /// The viewer's role in a newsletter. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] +#[non_exhaustive] pub enum NewsletterRole { Owner, Admin, @@ -64,7 +68,7 @@ pub enum NewsletterRole { } /// Metadata for a newsletter (channel). -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct NewsletterMetadata { pub jid: Jid, pub name: String, diff --git a/src/features/presence.rs b/src/features/presence.rs index 94411800a..a3dd79436 100644 --- a/src/features/presence.rs +++ b/src/features/presence.rs @@ -17,6 +17,7 @@ pub enum PresenceError { /// Presence status for online/offline state. #[derive(Debug, Clone, Copy, PartialEq, Eq, StringEnum)] +#[non_exhaustive] pub enum PresenceStatus { #[str = "available"] Available, diff --git a/src/features/status.rs b/src/features/status.rs index 61b9ec751..33b8faf93 100644 --- a/src/features/status.rs +++ b/src/features/status.rs @@ -9,6 +9,7 @@ use crate::upload::UploadResponse; /// Privacy setting sent in the `` node of the status stanza. /// Matches WhatsApp Web's `status_setting` attribute. #[derive(Debug, Clone, Copy, PartialEq, Eq, StringEnum)] +#[non_exhaustive] pub enum StatusPrivacySetting { /// Send to all contacts in address book. #[string_default] @@ -48,7 +49,7 @@ impl<'a> Status<'a> { text: &str, background_argb: u32, font: i32, - recipients: Vec, + recipients: &[Jid], options: StatusSendOptions, ) -> Result { let message = wa::Message { @@ -75,7 +76,7 @@ impl<'a> Status<'a> { upload: &UploadResponse, thumbnail: Vec, caption: Option<&str>, - recipients: Vec, + recipients: &[Jid], options: StatusSendOptions, ) -> Result { let message = wa::Message { @@ -109,7 +110,7 @@ impl<'a> Status<'a> { thumbnail: Vec, duration_seconds: u32, caption: Option<&str>, - recipients: Vec, + recipients: &[Jid], options: StatusSendOptions, ) -> Result { let message = wa::Message { @@ -140,7 +141,7 @@ impl<'a> Status<'a> { pub async fn send_raw( &self, message: wa::Message, - recipients: Vec, + recipients: &[Jid], options: StatusSendOptions, ) -> Result { self.client @@ -155,7 +156,7 @@ impl<'a> Status<'a> { pub async fn revoke( &self, message_id: impl Into, - recipients: Vec, + recipients: &[Jid], options: StatusSendOptions, ) -> Result { let message_id = message_id.into(); @@ -187,10 +188,10 @@ impl Client { /// # Example /// ```no_run /// # async fn example(client: &whatsapp_rust::Client) -> anyhow::Result<()> { - /// let recipients = vec![whatsapp_rust::Jid::pn("15551234567")]; + /// let recipients = [whatsapp_rust::Jid::pn("15551234567")]; /// let id = client /// .status() - /// .send_text("Hello!", 0xFF1E6E4F, 0, recipients, Default::default()) + /// .send_text("Hello!", 0xFF1E6E4F, 0, &recipients, Default::default()) /// .await?; /// # Ok(()) /// # } diff --git a/src/send.rs b/src/send.rs index 018a2f397..987e68480 100644 --- a/src/send.rs +++ b/src/send.rs @@ -29,7 +29,7 @@ pub struct SendOptions { } /// Result of a successfully sent message. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct SendResult { pub message_id: String, pub to: Jid, @@ -49,6 +49,7 @@ impl SendResult { /// Duration for pinned messages. Default is 7 days (matches WA Web). #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] +#[non_exhaustive] pub enum PinDuration { Hours24, #[default] @@ -68,6 +69,7 @@ impl PinDuration { /// Specifies who is revoking (deleting) the message. #[derive(Debug, Clone, PartialEq, Eq, Default)] +#[non_exhaustive] pub enum RevokeType { /// The message sender deleting their own message. #[default] @@ -275,7 +277,7 @@ impl Client { pub(crate) async fn send_status_message( &self, message: wa::Message, - recipients: Vec, + recipients: &[Jid], options: crate::features::status::StatusSendOptions, ) -> Result { use wacore::client::context::GroupInfo; @@ -326,7 +328,7 @@ impl Client { )); } } else { - resolved_recipients.push(jid); + resolved_recipients.push(jid.clone()); } }