pub struct Jid {
pub user: String,
pub server: String,
pub agent: u8,
pub device: u16,
pub integrator: u16,
}Fields§
§user: String§server: String§agent: u8§device: u16§integrator: u16Implementations§
Source§impl Jid
impl Jid
pub fn new(user: &str, server: &str) -> Self
Sourcepub fn status_broadcast() -> Self
pub fn status_broadcast() -> Self
Creates the status@broadcast JID used for status/story updates.
Sourcepub fn pn_device(user: impl Into<String>, device: u16) -> Self
pub fn pn_device(user: impl Into<String>, device: u16) -> Self
Create a phone number JID with device ID
Sourcepub fn lid_device(user: impl Into<String>, device: u16) -> Self
pub fn lid_device(user: impl Into<String>, device: u16) -> Self
Create a LID JID with device ID
Sourcepub fn user_base(&self) -> &str
pub fn user_base(&self) -> &str
Returns the user part without the device ID suffix (e.g., “123:4” -> “123”)
Sourcepub fn with_device(&self, device_id: u16) -> Self
pub fn with_device(&self, device_id: u16) -> Self
Helper to construct a specific device JID from this one
pub fn actual_agent(&self) -> u8
pub fn to_non_ad(&self) -> Self
Sourcepub fn matches_user_or_lid(&self, user: &Jid, lid: Option<&Jid>) -> bool
pub fn matches_user_or_lid(&self, user: &Jid, lid: Option<&Jid>) -> bool
Check if this JID matches the user or their LID. Useful for checking if a participant is “us” in group messages.
Sourcepub fn normalize_for_prekey_bundle(&self) -> Self
pub fn normalize_for_prekey_bundle(&self) -> Self
Normalize the JID for use in pre-key bundle storage and lookup.
WhatsApp servers may return JIDs with varied agent fields, or we might derive them with agent fields in some contexts. However, pre-key bundles are stored and looked up using a normalized key where the agent is 0 for standard servers (s.whatsapp.net, lid).
pub fn to_ad_string(&self) -> String
Sourcepub fn device_eq(&self, other: &Jid) -> bool
pub fn device_eq(&self, other: &Jid) -> bool
Compare device identity (user, server, device) without allocation.
Sourcepub fn device_key(&self) -> DeviceKey<'_>
pub fn device_key(&self) -> DeviceKey<'_>
Get a borrowing key for O(1) HashSet lookups by device identity.