pub struct Jid {
pub user: CompactString,
pub server: Server,
pub agent: u8,
pub device: u16,
pub integrator: u16,
}Fields§
§user: CompactString§server: Server§agent: u8§device: u16§integrator: u16Implementations§
Source§impl Jid
impl Jid
pub fn new(user: impl Into<CompactString>, server: Server) -> Self
Sourcepub fn pn(user: impl Into<CompactString>) -> Self
pub fn pn(user: impl Into<CompactString>) -> Self
Create a phone number JID (s.whatsapp.net)
Sourcepub fn lid(user: impl Into<CompactString>) -> Self
pub fn lid(user: impl Into<CompactString>) -> Self
Create a LID JID (lid server)
Sourcepub fn status_broadcast() -> Self
pub fn status_broadcast() -> Self
Creates the status@broadcast JID used for status/story updates.
Sourcepub fn group(id: impl Into<CompactString>) -> Self
pub fn group(id: impl Into<CompactString>) -> Self
Create a group JID (g.us).
Create a newsletter (channel) JID (newsletter server).
Sourcepub fn pn_device(user: impl Into<CompactString>, device: u16) -> Self
pub fn pn_device(user: impl Into<CompactString>, device: u16) -> Self
Create a phone number JID with device ID
Sourcepub fn lid_device(user: impl Into<CompactString>, device: u16) -> Self
pub fn lid_device(user: impl Into<CompactString>, 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 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 push_to(&self, buf: &mut String)
pub fn push_to(&self, buf: &mut String)
Append the Display representation to buf using direct push operations,
bypassing fmt::Display and dyn Write dispatch.
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.
Trait Implementations§
Source§impl JidExt for Jid
impl JidExt for Jid
fn user(&self) -> &str
fn server(&self) -> Server
fn device(&self) -> u16
fn integrator(&self) -> u16
fn is_ad(&self) -> bool
fn is_interop(&self) -> bool
fn is_messenger(&self) -> bool
fn is_group(&self) -> bool
fn is_broadcast_list(&self) -> bool
fn is_status_broadcast(&self) -> bool
fn is_bot(&self) -> bool
Source§fn is_hosted(&self) -> bool
fn is_hosted(&self) -> bool
fn is_empty(&self) -> bool
fn is_same_user_as(&self, other: &impl JidExt) -> bool
impl Eq for Jid
impl StructuralPartialEq for Jid
Auto Trait Implementations§
impl Freeze for Jid
impl RefUnwindSafe for Jid
impl Send for Jid
impl Sync for Jid
impl Unpin for Jid
impl UnsafeUnpin for Jid
impl UnwindSafe for Jid
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more