Skip to main content

Jid

Struct Jid 

Source
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: u16

Implementations§

Source§

impl Jid

Source

pub fn new(user: impl Into<CompactString>, server: Server) -> Jid

Source

pub fn pn(user: impl Into<CompactString>) -> Jid

Create a phone number JID (s.whatsapp.net)

Source

pub fn lid(user: impl Into<CompactString>) -> Jid

Create a LID JID (lid server)

Source

pub fn status_broadcast() -> Jid

Creates the status@broadcast JID used for status/story updates.

Source

pub fn group(id: impl Into<CompactString>) -> Jid

Create a group JID (g.us).

Source

pub fn newsletter(id: impl Into<CompactString>) -> Jid

Create a newsletter (channel) JID (newsletter server).

Source

pub fn pn_device(user: impl Into<CompactString>, device: u16) -> Jid

Create a phone number JID with device ID

Source

pub fn lid_device(user: impl Into<CompactString>, device: u16) -> Jid

Create a LID JID with device ID

Source

pub fn is_pn(&self) -> bool

Returns true if this is a Phone Number based JID (s.whatsapp.net)

Source

pub fn is_lid(&self) -> bool

Returns true if this is a LID based JID

Source

pub fn user_base(&self) -> &str

Returns the user part without the device ID suffix (e.g., “123:4” -> “123”)

Source

pub fn with_device(&self, device_id: u16) -> Jid

Helper to construct a specific device JID from this one

Source

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.

Source

pub fn to_non_ad(&self) -> Jid

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn write_display_to<W>(&self, writer: &mut W) -> Result<(), Error>
where W: Write + ?Sized,

Write the Display representation to any fmt::Write sink without an intermediate String.

Source

pub fn display_eq(&self, other: &str) -> bool

Compare the display representation with other without allocating.

Source

pub fn display_eq_jid(&self, other: &Jid) -> bool

Compare two JIDs by the representation emitted by fmt::Display.

Source

pub fn device_eq(&self, other: &Jid) -> bool

Compare device identity (user, server, device) without allocation.

Source

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.

Source

pub fn device_key(&self) -> DeviceKey<'_>

Get a borrowing key for O(1) HashSet lookups by device identity.

Source§

impl Jid

Source

pub fn observe(&self) -> ObservedJid<'_>

Privacy-aware display for tracing spans/fields. See ObservedJid.

Trait Implementations§

Source§

impl Clone for Jid

Source§

fn clone(&self) -> Jid

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Jid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Jid

Source§

fn default() -> Jid

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Jid

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Jid, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Jid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl DsmDestination for Jid

Source§

fn encoded_len(&self) -> usize

Exactly the number of bytes Self::write_into appends. Read more
Source§

fn write_into(&self, out: &mut Vec<u8>)

Appends the destination’s wire form, whose length must equal Self::encoded_len.
Source§

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.

Source§

fn from(jid: &Jid) -> Jid

Converts to this type from the input type.
Source§

impl FromStr for Jid

Source§

type Err = JidError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Jid, <Jid as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Jid

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl HeapSize for Jid

Source§

impl JidExt for Jid

Source§

fn to_signal_address_string(&self) -> String

Source§

fn to_protocol_address(&self) -> ProtocolAddress

Source§

fn to_protocol_address_string(&self) -> String

Source§

fn reset_protocol_address(&self, addr: &mut ProtocolAddress)

Rewrite a reusable ProtocolAddress in place for this JID. Writes directly into the address — no intermediate buffer needed.
Source§

impl JidExt for Jid

Source§

fn user(&self) -> &str

Source§

fn server(&self) -> Server

Source§

fn device(&self) -> u16

Source§

fn integrator(&self) -> u16

Source§

fn is_ad(&self) -> bool

Source§

fn is_interop(&self) -> bool

Source§

fn is_messenger(&self) -> bool

Source§

fn is_group(&self) -> bool

Source§

fn is_broadcast_list(&self) -> bool

Source§

fn is_status_broadcast(&self) -> bool

Source§

fn is_psa(&self) -> bool

The system/announcements account (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).
Source§

fn is_bot(&self) -> bool

Source§

fn is_newsletter(&self) -> bool

Source§

fn is_hosted(&self) -> bool

Returns true if this is a hosted/Cloud API device. Hosted devices have device ID 99 or use @hosted/@hosted.lid server. These devices should be excluded from group message fanout.
Source§

fn is_empty(&self) -> bool

Source§

fn is_same_user_as(&self, other: &impl JidExt) -> bool

Source§

impl PartialEq for Jid

Source§

fn eq(&self, other: &Jid) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<JidRef<'_>> for Jid

Source§

fn eq(&self, other: &JidRef<'_>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Jid

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<String> for Jid

Source§

type Error = JidError

The type returned in the event of a conversion error.
Source§

fn try_from(value: String) -> Result<Jid, <Jid as TryFrom<String>>::Error>

Performs the conversion.

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

Source§

fn aggregate_distinct(self) -> Self::Output
where Self: DistinctDsl,

DISTINCT modifier for aggregate functions Read more
Source§

fn aggregate_all(self) -> Self::Output
where Self: AllDsl,

ALL modifier for aggregate functions Read more
Source§

fn aggregate_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add an aggregate function filter Read more
Source§

fn aggregate_order<O>(self, o: O) -> Self::Output
where Self: OrderAggregateDsl<O>,

Add an aggregate function order Read more
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoSql for T

Source§

fn into_sql<T>(self) -> Self::Expression

Convert self to an expression for Diesel’s query builder. Read more
Source§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Spawnable for T
where T: Send + 'static,

Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WindowExpressionMethods for T

Source§

fn over(self) -> Self::Output
where Self: OverDsl,

Turn a function call into a window function call Read more
Source§

fn window_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add a filter to the current window function Read more
Source§

fn partition_by<E>(self, expr: E) -> Self::Output
where Self: PartitionByDsl<E>,

Add a partition clause to the current window function Read more
Source§

fn window_order<E>(self, expr: E) -> Self::Output
where Self: OrderWindowDsl<E>,

Add a order clause to the current window function Read more
Source§

fn frame_by<E>(self, expr: E) -> Self::Output
where Self: FrameDsl<E>,

Add a frame clause to the current window function Read more