From 7bf9dae72f1a1c8dd3645fbccb820c15764b2b36 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Lucas?=
<55464917+jlucaso1@users.noreply.github.com>
Date: Tue, 21 Jul 2026 20:38:52 -0300
Subject: [PATCH 1/8] feat(core): expose typed stanza responses and retries
---
src/client.rs | 68 ++--
src/client/node_io.rs | 45 ++-
src/client/tests.rs | 120 +++++-
src/features/mod.rs | 5 +
src/features/stanza.rs | 203 +++++++++++
src/lib.rs | 11 +-
src/message.rs | 4 +-
src/message/retry.rs | 152 +++++---
src/message/tests.rs | 609 ++++++++++++++++++++++++++++++-
src/portable_cache.rs | 81 ++++
src/prekeys.rs | 9 +-
src/receipt.rs | 337 +++++++++++++++--
src/retry.rs | 258 +++----------
tests/e2e/tests/app_state.rs | 2 +
tests/e2e/tests/chat_actions.rs | 2 +
tests/e2e/tests/memory_soak.rs | 9 +
tests/e2e/tests/messaging.rs | 2 +
tests/e2e/tests/profile.rs | 2 +
wacore/binary/src/jid.rs | 62 ++++
wacore/binary/src/node.rs | 79 ++--
wacore/src/message_processing.rs | 3 +-
wacore/src/protocol/nack.rs | 13 +-
wacore/src/protocol/retry.rs | 60 ++-
23 files changed, 1720 insertions(+), 416 deletions(-)
create mode 100644 src/features/stanza.rs
diff --git a/src/client.rs b/src/client.rs
index 3562d9ab5..d8d136367 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -1044,6 +1044,22 @@ fn build_pong(to: String, id: Option<&str>) -> wacore_binary::Node {
builder.build()
}
+/// Compare decoded attribute values by their wire display without allocating.
+#[inline]
+fn value_refs_display_equal(
+ left: &wacore_binary::node::ValueRef<'_>,
+ right: &wacore_binary::node::ValueRef<'_>,
+) -> bool {
+ use wacore_binary::node::ValueRef;
+
+ match (left, right) {
+ (ValueRef::String(left), ValueRef::String(right)) => left == right,
+ (ValueRef::Jid(left), ValueRef::Jid(right)) => left == right,
+ (ValueRef::String(left), ValueRef::Jid(right)) => right.display_eq(left),
+ (ValueRef::Jid(left), ValueRef::String(right)) => left.display_eq(right),
+ }
+}
+
/// Build an `` for the given stanza, matching WA Web / whatsmeow behavior:
///
/// - `class` = original stanza tag
@@ -1056,32 +1072,37 @@ fn build_pong(to: String, id: Option<&str>) -> wacore_binary::Node {
/// `ackString = maybeAttrString("type")` — so `type` is only included when
/// explicitly present on the incoming receipt (delivery receipts normally
/// have no type attribute, meaning the ack also has no type).
+///
/// Encode an ack stanza directly to bytes, bypassing Node + marshal_auto.
/// Acks are the most frequent outbound stanza (~1 per inbound message).
fn encode_ack_bytes(
node: &wacore_binary::NodeRef<'_>,
own_device_pn: Option<&Jid>,
-) -> Result