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) -> Jid
Sourcepub fn pn(user: impl Into<CompactString>) -> Jid
pub fn pn(user: impl Into<CompactString>) -> Jid
Create a phone number JID (s.whatsapp.net)
Sourcepub fn lid(user: impl Into<CompactString>) -> Jid
pub fn lid(user: impl Into<CompactString>) -> Jid
Create a LID JID (lid server)
Sourcepub fn status_broadcast() -> Jid
pub fn status_broadcast() -> Jid
Creates the status@broadcast JID used for status/story updates.
Sourcepub fn group(id: impl Into<CompactString>) -> Jid
pub fn group(id: impl Into<CompactString>) -> Jid
Create a group JID (g.us).
Create a newsletter (channel) JID (newsletter server).
Sourcepub fn pn_device(user: impl Into<CompactString>, device: u16) -> Jid
pub fn pn_device(user: impl Into<CompactString>, device: u16) -> Jid
Create a phone number JID with device ID
Sourcepub fn lid_device(user: impl Into<CompactString>, device: u16) -> Jid
pub fn lid_device(user: impl Into<CompactString>, device: u16) -> Jid
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) -> Jid
pub fn with_device(&self, device_id: u16) -> Jid
Helper to construct a specific device JID from this one
Sourcepub fn with_device_hosting(&self, device_id: u16, is_hosted: bool) -> Jid
pub fn with_device_hosting(&self, device_id: u16, is_hosted: bool) -> Jid
Construct a device JID and select the hosted variant of PN/LID when indicated by a device-list entry.
Non-user namespaces are left unchanged because they have no hosted counterpart on the wire.
pub fn to_non_ad(&self) -> Jid
Sourcepub fn into_non_ad(self) -> Jid
pub fn into_non_ad(self) -> Jid
Consuming to_non_ad: reuses the owned user instead of cloning it.
Prefer this when the receiver is a throwaway owned Jid.
Sourcepub fn is_same_chat_as(&self, other: &Jid) -> bool
pub fn is_same_chat_as(&self, other: &Jid) -> bool
Device-insensitive “same chat” check: two JIDs address the same chat when
they render to the same string ignoring the multi-device device. Compares
user, server, integrator, and agent only where the server renders
the agent (@bot/@interop); Pn/Lid/Hosted suppress it in display, so a
stray decoded agent byte there must not split the chat. Allocates nothing.
Stricter than is_same_user_as, which ignores server.
Sourcepub fn to_non_ad_string(&self) -> String
pub fn to_non_ad_string(&self) -> String
Canonical non-AD string form (user@server, device + agent stripped)
in a single allocation. Equivalent to to_non_ad().to_string() but
skips the throwaway intermediate Jid and its CompactString clone.
Sourcepub fn to_non_ad_arc_str(&self) -> Arc<str> ⓘ
pub fn to_non_ad_arc_str(&self) -> Arc<str> ⓘ
Self::to_non_ad_string as a shareable Arc<str>, in exactly one
allocation. Going through the String first costs two — the buffer, then
the Arc<str> its bytes are copied into — and the message-secret rows
build two of these per message.
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 to_phash_form_string(&self) -> String
pub fn to_phash_form_string(&self) -> String
See Jid::push_phash_form_to. Not a general JID rendering — use
Display/to_string for that.
Sourcepub fn push_phash_form_to(&self, buf: &mut String)
pub fn push_phash_form_to(&self, buf: &mut String)
Append the form the participant hash is computed over
(user.0:device@server) to buf, for callers that batch many JIDs into
one shared buffer instead of paying a heap String per JID (see
participant_list_hash).
This is not a general-purpose JID rendering. The agent position is
the literal 0, never self.agent, and that is deliberate: WA Web’s
formatFull spelling hardcodes ".0" unconditionally — there is no
per-server carve-out, and WAWebWid has no agent field to read one from.
The server recomputes this exact string to validate the phash, so writing
our agent would mean a rejected hash for any JID that carried one.
If you want the JID as it is addressed, including the agent on the servers
that render it, use Display / Jid::push_to instead.
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 write_display_to<W>(&self, writer: &mut W) -> Result<(), Error>
pub fn write_display_to<W>(&self, writer: &mut W) -> Result<(), Error>
Write the Display representation to any fmt::Write sink without an
intermediate String.
Sourcepub fn display_eq(&self, other: &str) -> bool
pub fn display_eq(&self, other: &str) -> bool
Compare the display representation with other without allocating.
Sourcepub fn display_eq_jid(&self, other: &Jid) -> bool
pub fn display_eq_jid(&self, other: &Jid) -> bool
Compare two JIDs by the representation emitted by fmt::Display.
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 identity_agent(&self) -> u8
pub fn identity_agent(&self) -> u8
The agent as far as identity is concerned: the field itself where the
server renders it (@bot, @interop), 0 where it does not.
Exposed so callers that build their own key over a JID — sorting,
deduplicating, indexing — can key on the same rule == and Hash use
instead of on the raw field, which would split one device in two or, in
reverse, merge two real ones.
Sourcepub fn device_key(&self) -> DeviceKey<'_>
pub fn device_key(&self) -> DeviceKey<'_>
Get a borrowing key for O(1) HashSet lookups by device identity.
Source§impl Jid
impl Jid
Sourcepub fn observe(&self) -> ObservedJid<'_>
pub fn observe(&self) -> ObservedJid<'_>
Privacy-aware display for tracing spans/fields. See ObservedJid.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Jid
impl<'de> Deserialize<'de> for Jid
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Jid, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Jid, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl DsmDestination for Jid
impl DsmDestination for Jid
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Self::write_into appends. Read moreSource§fn write_into(&self, out: &mut Vec<u8>)
fn write_into(&self, out: &mut Vec<u8>)
Self::encoded_len.impl Eq for Jid
Source§impl From<&Jid> for Jid
Lets impl Into<Jid> APIs accept &Jid transparently: borrow-callers pay
one cheap clone (the user part is inline for typical numeric ids), owned
callers move for free.
impl From<&Jid> for Jid
Lets impl Into<Jid> APIs accept &Jid transparently: borrow-callers pay
one cheap clone (the user part is inline for typical numeric ids), owned
callers move for free.
Source§impl JidExt for Jid
impl JidExt for Jid
fn to_signal_address_string(&self) -> String
fn to_protocol_address(&self) -> ProtocolAddress
fn to_protocol_address_string(&self) -> String
Source§fn reset_protocol_address(&self, addr: &mut ProtocolAddress)
fn reset_protocol_address(&self, addr: &mut ProtocolAddress)
ProtocolAddress in place for this JID.
Writes directly into the address — no intermediate buffer needed.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
Source§fn is_psa(&self) -> bool
fn is_psa(&self) -> bool
0@s.whatsapp.net / 0@c.us).
It never answers user-directed IQs, so requests must be short-circuited
client-side (WA Web excludes it via isPSA before hitting the server).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
Source§impl Serialize for Jid
impl Serialize for Jid
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read moreimpl<T> MaybeSend for T
impl<T> MaybeSendSync for T
impl<T> Spawnable for Twhere
T: Send + 'static,
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