Skip to main content

Jid

Struct Jid 

Source
pub struct Jid {
    pub user: String,
    pub server: Cow<'static, str>,
    pub agent: u8,
    pub device: u16,
    pub integrator: u16,
}

Fields§

§user: String§server: Cow<'static, str>§agent: u8§device: u16§integrator: u16

Implementations§

Source§

impl Jid

Source

pub fn new(user: &str, server: &str) -> Jid

Source

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

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

Source

pub fn lid(user: impl Into<String>) -> 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<String>) -> Jid

Create a group JID (g.us).

Source

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

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

Source

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

Create a phone number JID with device ID

Source

pub fn lid_device(user: impl Into<String>, 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 actual_agent(&self) -> u8

Source

pub fn to_non_ad(&self) -> Jid

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 normalize_for_prekey_bundle(&self) -> Jid

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

Source

pub fn to_ad_string(&self) -> String

Source

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

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

Source

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

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

Trait Implementations§

Source§

impl Clone for Jid

Source§

fn clone(&self) -> Jid

Returns a duplicate of the value. Read more
1.0.0 · 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 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 JidExt for Jid

Source§

fn to_protocol_address(&self) -> ProtocolAddress

Build a ProtocolAddress for Signal session store lookups. The device_id is always 0 — WhatsApp encodes the device in the name.

Source§

fn to_signal_address_string(&self) -> String

Returns the Signal address string in WhatsApp Web format. Format: {user}[:device]@{server} Read more
Source§

fn to_protocol_address_string(&self) -> String

Returns the full protocol address string including the device_id suffix. Format: {signal_address_string}.0 This is equivalent to to_protocol_address().to_string() but avoids the intermediate ProtocolAddress allocation — one String instead of two.
Source§

impl JidExt for Jid

Source§

fn user(&self) -> &str

Source§

fn server(&self) -> &str

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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.
Source§

impl Eq for Jid

Source§

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

Compare self to key and return true if they are equal.
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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
Source§

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