Skip to content

refactor(api): rustdoc for entry types, must_use, root re-exports, and constructor consistency - #1089

Merged
jlucaso1 merged 3 commits into
mainfrom
claude/api-ergonomia-consistencia-8b2u2u
Jul 24, 2026
Merged

refactor(api): rustdoc for entry types, must_use, root re-exports, and constructor consistency#1089
jlucaso1 merged 3 commits into
mainfrom
claude/api-ergonomia-consistencia-8b2u2u

Conversation

@jlucaso1

Copy link
Copy Markdown
Collaborator

Summary

An ergonomics pass over the public API surface: the two entry types (Client and Bot) had no rustdoc at all, a few builders could be dropped silently with no warning, and a handful of types and constructors drifted from the conventions their siblings already follow. No behavior changes, only surface.

Changes

  • Rustdoc for Client and Bot. What each one is, how to get one (ClientBuilder vs Bot::builder()), and pointers to the lifecycle (run/connect/disconnect), the event bus, and sending. Bot also gets a short quick-start example.
  • #[must_use] on BotHandle, BotBuilder and ClientBuilder. Dropping a BotHandle aborts the bot, which is easy to do by accident, so the message says so; the builders get the usual "call .build()".
  • Root re-exports. Polls, PollOptionResult, PollVoteCiphertext, MexGraphQLError and EncType are now re-exported from the crate root alongside Groups/Contacts/Mex.
  • Dropped the get_ prefix from Client::get_push_name/get_pn/get_lidpush_name/pn/lid, matching the neighbouring accessors. Breaking; all workspace call sites updated.
  • &Jid/&[Jid] in IqSpec constructors. AcceptGroupInviteV4Iq::new took owned Jid/String, and BatchGetGroupInfoIq::new/GetGroupProfilePicturesIq::new took Vec<Jid>, while their siblings take references. They now take references and clone internally, per agent_docs/protocol_architecture.md. GetGroupProfilePicturesIq::with_type moved with new so the type stays internally consistent. Breaking for direct IqSpec users.
  • Sealed SendOptions and EditOptions with #[non_exhaustive] plus chainable with_* setters (SendOptions::default().with_message_id(id)). bon is feature-gated behind plugins in this crate, so hand-rolled setters were the option that does not pull a new unconditional dependency. Breaking for out-of-crate struct-literal construction; e2e call sites updated.
  • Documented Groups::query_info vs Groups::get_metadata. Not renamed, only explained: query_info returns the slim, phash-refreshed, cached Arc<GroupInfo> the send path needs, while get_metadata always goes to the network for the full GroupMetadata.

Validation

cargo fmt --all --check
cargo clippy --workspace --all-targets -- -D warnings   # locally minus whatsapp-rust-voip-cli, which needs ALSA/pkg-config
cargo test -p whatsapp-rust --lib                       # 1136 passed
cargo test -p whatsapp-rust --doc
cargo check -p whatsapp-rust --lib --no-default-features # guards the wasm32 build path

e2e was not run locally; CI covers it.


Generated by Claude Code

…d constructor consistency

Ergonomics pass over the public surface, no behavior changes.

- Document Client and Bot, the two entry points, including how to build
  them and where run/send/events live.
- Mark BotHandle, BotBuilder and ClientBuilder #[must_use]; dropping a
  BotHandle silently aborts the bot, and a dropped builder does nothing.
- Re-export Polls, PollOptionResult, PollVoteCiphertext, MexGraphQLError
  and EncType from the crate root, like their feature siblings.
- Drop the get_ prefix from Client::get_push_name/get_pn/get_lid so they
  match the surrounding accessors.
- Take &Jid/&[Jid] in AcceptGroupInviteV4Iq, BatchGetGroupInfoIq and
  GetGroupProfilePicturesIq constructors, per the IqSpec convention.
- Seal SendOptions and EditOptions with #[non_exhaustive] and add with_*
  setters so fields can be added without breaking consumers.
- Explain when to use Groups::query_info (cached, send oriented) versus
  Groups::get_metadata (full, always over the network).
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@jlucaso1, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 seconds

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 745ac34a-c264-44b6-8b1d-007aff704695

📥 Commits

Reviewing files that changed from the base of the PR and between d6f2bda and 511eb7b.

📒 Files selected for processing (2)
  • src/features/groups.rs
  • src/send/mod.rs
📝 Walkthrough

Walkthrough

The PR renames client identity accessors, adds fluent send-option setters, changes group IQ constructors to borrow inputs, documents public APIs, adds #[must_use] annotations, re-exports MexGraphQLError, and updates production and test call sites.

Changes

API migration

Layer / File(s) Summary
Public API contracts and documentation
src/bot.rs, src/client.rs, src/client/accessors.rs, src/client/builder.rs, src/send/mod.rs, src/features/groups.rs, src/lib.rs
Public types and APIs gain documentation, must-use diagnostics, renamed identity accessors, fluent option setters, and an additional public re-export.
Borrowed group IQ APIs
wacore/src/iq/groups.rs, src/features/groups.rs
Group IQ constructors accept borrowed JIDs, strings, slices, and group tuples while cloning into owned fields; callers pass references.
Production identity accessor migration
src/client/*, src/features/*, src/message/*, src/send/mod.rs, src/handlers/call.rs, src/history_sync.rs, src/voip/facade.rs
Runtime code replaces get_pn, get_lid, and get_push_name calls with pn, lid, and push_name without changing surrounding control flow.
Test and helper migration
tests/e2e/*, src/voip/facade.rs, src/message/tests.rs, src/features/polls.rs, wacore/src/stanza/call.rs
Tests and helpers adopt the renamed accessors and fluent SendOptions construction while preserving existing assertions and scenarios.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested labels: api-design, breaking-change

Suggested reviewers: greptile-apps

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the API refactor, docs, must_use, re-exports, and constructor consistency changes.
Description check ✅ Passed The description clearly matches the changeset and explains the public API ergonomics refactor.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/api-ergonomia-consistencia-8b2u2u

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 24, 2026

Copy link
Copy Markdown

Greptile Summary

This is an ergonomics pass over the public API: no behavior changes, only surface refinements. All workspace call sites are updated and the validation matrix (fmt, clippy, lib tests, doc tests, wasm check) is covered.

  • Accessor renames (get_push_name/get_pn/get_lidpush_name/pn/lid) are applied consistently across all 36 changed files, including the voip facade, e2e test helpers, and internal call handlers.
  • SendOptions / EditOptions gain #[non_exhaustive] and #[must_use] with_* setters; BotHandle, BotBuilder, and ClientBuilder gain #[must_use]; IqSpec constructors in wacore are normalised to &Jid / &[Jid].
  • New root re-exports (Polls, PollOptionResult, PollVoteCiphertext, MexGraphQLError, EncType) and comprehensive rustdoc for Client and Bot are additive and don't affect runtime.

Confidence Score: 5/5

Safe to merge — all changes are additive documentation, attribute-only annotations, or mechanical renames with every call site updated.

The rename of get_push_name/get_pn/get_lid is applied exhaustively across all 36 files in the workspace. The IqSpec constructor changes match the documented convention and the tests are updated. The #[non_exhaustive] + with_* pattern on SendOptions/EditOptions is self-consistent: the one internal struct literal (EditOptions { stanza_id: … } at line 2843 in src/send/mod.rs) is inside the defining crate and remains valid. No logic paths are altered.

No files require special attention.

Important Files Changed

Filename Overview
src/bot.rs Adds comprehensive rustdoc to Bot (with a no_run quickstart example) and BotBuilder (#[must_use]); BotHandle gains #[must_use] with correct drop-aborts message.
src/client.rs Adds comprehensive rustdoc to Client covering lifecycle, event bus, and send API; no logic changes.
src/client/accessors.rs Renames get_push_name/get_pn/get_lid to push_name/pn/lid and adds rustdoc; internal require_pn updated correctly.
src/client/builder.rs ClientBuilder gains #[must_use] with the conventional 'call .build()' message; no other changes.
src/send/mod.rs Adds #[non_exhaustive] + #[must_use] with_* setters to SendOptions and EditOptions; internal EditOptions struct-literal at line 2843 stays valid (inside crate). All accessor renames applied.
src/features/groups.rs Adds rustdoc distinguishing query_info (cached, send-path) from get_metadata (network, full); IqSpec call sites updated to pass references.
src/lib.rs Adds root re-exports: EncType, MexGraphQLError, PollOptionResult, PollVoteCiphertext, Polls. No removed exports.
wacore/src/iq/groups.rs AcceptGroupInviteV4Iq::new, BatchGetGroupInfoIq::new, and GetGroupProfilePicturesIq::new/with_type changed from owned types to &Jid/&[Jid] with internal clone/to_vec; tests updated.
src/message/msg_secret.rs Accessor renames applied across several address-mode dispatch branches; logic unchanged.
tests/e2e/src/lib.rs All get_pn/get_lid/get_push_name call sites in the shared test helper updated to the new names.

Reviews (2): Last reviewed commit: "docs(groups): correct query_info cache a..." | Re-trigger Greptile

Comment thread src/send/mod.rs
@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown

📦 Binary size report

Metric main PR Δ
bin size (stripped) 9.88 MiB 9.88 MiB 0
bin .text 7.93 MiB 7.93 MiB 0
bin allocated (text+data+bss) 9.88 MiB 9.88 MiB 0
llvm-lines wacore 490,042 490,362 +320 (+0.07%) 🔺
llvm-lines wacore copies 16,306 16,315 +9 (+0.06%) 🔺
llvm-lines whatsapp-rust lib 685,672 685,676 +4 (+0.00%) 🔺
llvm-lines whatsapp-rust lib copies 21,857 21,858 +1 (+0.00%) 🔺
deps crates (Cargo.lock) 471 471 0
.text per crate
Crate main PR Δ
.text whatsapp_rust 1.73 MiB 1.73 MiB 0
.text wacore 653.72 KiB 654.02 KiB +312 B (+0.05%) 🔺
.text wacore_binary 89.42 KiB 89.42 KiB 0
.text wacore_libsignal 161.89 KiB 161.89 KiB 0
.text wacore_appstate 22.36 KiB 22.36 KiB 0
.text wacore_noise 22.98 KiB 22.98 KiB 0
.text waproto 1.74 MiB 1.74 MiB 0
.text whatsapp_rust_sqlite_storage 510.95 KiB 510.95 KiB 0
.text whatsapp_rust_tokio_transport 39.78 KiB 39.78 KiB 0
.text whatsapp_rust_ureq_http_client 10.36 KiB 10.36 KiB 0
.text std 1.06 MiB 1.06 MiB 0
.text other deps 1.88 MiB 1.88 MiB -312 B (-0.02%) 🔽

Baseline: d7cfd555e (latest main run) · Head: b867cbc5a · Graphs

The with_* setters consume self and return Self, so discarding the
result silently drops the configured value.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/features/groups.rs`:
- Around line 370-382: The documentation for Groups::query_info incorrectly
implies stale cache entries are automatically revalidated. Update its
cache-semantics description to state that CachePreferred returns cached
GroupInfo immediately, while the persisted-phash/not-modified request occurs
only on a cache miss or explicit refresh; retain the existing guidance about
get_metadata and query_info_with_freshness.
- Around line 625-635: Update the get_metadata documentation to describe
participant phone-number resolution as best-effort: known LID→PN mappings
populate phone numbers, while unknown mappings remain unset. Remove wording that
promises complete or fully resolved phone numbers, while preserving the rest of
the metadata and caching behavior description.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 94822dd2-ecb2-4ca2-b765-7f08756f71ec

📥 Commits

Reviewing files that changed from the base of the PR and between d7cfd55 and d6f2bda.

📒 Files selected for processing (36)
  • src/bot.rs
  • src/client.rs
  • src/client/accessors.rs
  • src/client/builder.rs
  • src/client/messaging.rs
  • src/features/comments.rs
  • src/features/events.rs
  • src/features/groups.rs
  • src/features/polls.rs
  • src/features/reaction.rs
  • src/handlers/call.rs
  • src/history_sync.rs
  • src/lib.rs
  • src/message/msg_secret.rs
  • src/message/receive.rs
  • src/message/tests.rs
  • src/send/mod.rs
  • src/voip/facade.rs
  • tests/e2e/src/lib.rs
  • tests/e2e/tests/app_state.rs
  • tests/e2e/tests/chat_actions.rs
  • tests/e2e/tests/community.rs
  • tests/e2e/tests/groups.rs
  • tests/e2e/tests/lid_sessions.rs
  • tests/e2e/tests/media.rs
  • tests/e2e/tests/memory_soak.rs
  • tests/e2e/tests/prekey_sessions.rs
  • tests/e2e/tests/privacy_tokens.rs
  • tests/e2e/tests/profile.rs
  • tests/e2e/tests/profile_picture.rs
  • tests/e2e/tests/receipts.rs
  • tests/e2e/tests/retry_dm_multidevice.rs
  • tests/e2e/tests/session_reuse.rs
  • tests/e2e/tests/status.rs
  • wacore/src/iq/groups.rs
  • wacore/src/stanza/call.rs

Comment thread src/features/groups.rs
Comment thread src/features/groups.rs
…wording

query_info returns a cached entry as-is; the phash request happens only
on a miss. get_metadata backfills participant phone numbers on a
best-effort basis, so an unmapped LID stays unset.
@jlucaso1
jlucaso1 merged commit 25f56a0 into main Jul 24, 2026
16 checks passed
@jlucaso1
jlucaso1 deleted the claude/api-ergonomia-consistencia-8b2u2u branch July 24, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants