#[non_exhaustive]#[repr(u8)]pub enum Server {
Pn = 0,
Lid = 1,
Group = 2,
Broadcast = 3,
Newsletter = 4,
Hosted = 5,
HostedLid = 6,
Messenger = 7,
Interop = 8,
Bot = 9,
Call = 11,
}Expand description
Known WhatsApp server identifiers.
Maps to the wire protocol’s AD_JID domain type (u8) and the @server suffix
in JID string representation.
New supported namespaces may gain variants. Unknown namespaces are rejected by parsing; they are never mapped into a known identity class.
use wacore_binary::Server;
let server = Server::try_from("lid").unwrap();
let phone_namespace = match server {
Server::Pn | Server::Hosted => true,
_ => false,
};
assert!(!phone_namespace);
assert!(Server::try_from("future.invalid").is_err());Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Pn = 0
Lid = 1
Group = 2
Broadcast = 3
Newsletter = 4
Hosted = 5
HostedLid = 6
Messenger = 7
Interop = 8
Bot = 9
Call = 11
@call call-signaling JID; not an AD server, so it round-trips via JID_PAIR.
Implementations§
Source§impl Server
impl Server
pub fn as_str(self) -> &'static str
Sourcepub fn user_server(self) -> Self
pub fn user_server(self) -> Self
The account-level (non-hosted) server variant for this server:
Hosted -> Pn, HostedLid -> Lid. Other servers return themselves.
(Matches WA Web asUserWidOrThrow / createUserWidOrThrow mapping hosted -> c.us and hosted.lid -> lid).
Sourcepub fn with_hosting(self, is_hosted: bool) -> Self
pub fn with_hosting(self, is_hosted: bool) -> Self
Returns the hosted or non-hosted server variant within this server’s addressing family:
- PN family:
is_hosted?Hosted:Pn - LID family:
is_hosted?HostedLid:Lid - Other: unchanged
Sourcepub fn is_pn_family(self) -> bool
pub fn is_pn_family(self) -> bool
Phone-number-namespaced servers (@s.whatsapp.net, @hosted).
The PN side of the LID↔PN mapping treats these as a single class.
Sourcepub fn is_lid_family(self) -> bool
pub fn is_lid_family(self) -> bool
LID-namespaced servers (@lid, @hosted.lid).
Sourcepub fn renders_agent(self) -> bool
pub fn renders_agent(self) -> bool
Whether the agent byte is part of the rendered JID for this server.
AD-capable servers (Pn/Lid/Hosted/HostedLid) have no agent of their own —
their wire form spells the server as a domain byte, which the decoder
resolves into server rather than keeping — so an agent set on one is
meaningless and stays out of the rendered form. Others (e.g. @bot,
@interop) render it. Single source of truth shared by the formatter and
Jid::is_same_chat_as.
Sourcepub fn carries_phone_number(self) -> bool
pub fn carries_phone_number(self) -> bool
Whether the user part is (or can be) a real phone number, i.e. PII that
must be redacted in tracing fields. LID-family/group/broadcast/newsletter/
bot/call users are pseudonymous or non-personal and are safe to render raw.
Source§impl Server
impl Server
Sourcepub fn parse_known(s: &str) -> Option<Self>
pub fn parse_known(s: &str) -> Option<Self>
Allocation-free server lookup. TryFrom<&str> builds a JidError —
and therefore a String — for an unknown suffix, which the JID scanner
hits on every non-JID string it is asked to classify; this returns the
same answer without paying for the message nobody reads.
Trait Implementations§
impl Copy for Server
impl Eq for Server
Source§impl Ord for Server
impl Ord for Server
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Server
impl PartialOrd for Server
impl StructuralPartialEq for Server
Auto Trait Implementations§
impl Forget for Server
impl Freeze for Server
impl Move for Server
impl RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl UnsafeUnpin for Server
impl UnwindSafe for Server
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,
impl<T> ErasedDestructor for Twhere
T: '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