Skip to main content

Overview

waproto contains the Protocol Buffers definitions for all WhatsApp message types. It’s auto-generated from whatsapp.proto using prost and provides strongly-typed Rust structs for working with WhatsApp’s binary protocol.

Structure

The build writes whatsapp.rs and tags.rs to OUT_DIR. Do not commit these files.

Usage

All protobuf types are under the waproto::whatsapp module:

Key message types

Core message types

Message

The main message container used for all WhatsApp messages.
Usage in main library:

MessageKey

Identifies a specific message in a conversation.

Media Messages

ImageMessage

VideoMessage

AudioMessage

DocumentMessage

StickerMessage

Rich content messages

ExtendedTextMessage

Text with formatting, links, and quoted messages.

InteractiveMessage

Buttons, lists, and other interactive elements.

ButtonsMessage

ListMessage

Encryption Messages

SenderKeyDistributionMessage

Used for group message encryption.

PreKeySignalMessage

Used for establishing 1:1 encryption.

System & protocol messages

ProtocolMessage

For protocol-level operations.
Common types:
  • DELETE - Delete message for everyone
  • REVOKE - Revoke sent message
  • EPHEMERAL_SETTING - Ephemeral message setting

ReactionMessage

EditMessage

AlbumMessage

Parent message for grouped media albums. Declares expected image/video counts so WhatsApp clients know how many items to group together.
Each child media message is wrapped in associated_child_message (a FutureProofMessage) and linked to the parent via a MessageAssociation:
Use whatsapp_rust::proto_helpers::wrap_as_album_child to construct album children. See Sending Messages - Album messages for usage examples.

AI & bot messages

AiRichResponseMessage

BotFeedbackMessage

Metadata & Context

MessageContextInfo

ContextInfo

Quoted messages, mentions, and forwarding info.

Device & identity types

ADV Messages

Account Device Verification messages.

Signal protocol structures

Handshake & connection types

HandshakeMessage

Used during initial connection handshake.

ClientPayload

Device and client information during pairing.

History sync types

HistorySyncNotification

HistorySync

Media reference types

ExternalBlobReference

References to uploaded media files.

App state types

SyncActionValue

App state synchronization actions.

Enums

waproto includes many enum types (as i32 values with const definitions):

Feature flags

The generate feature was removed in #836. Code generation is now always-on — prost-build, heck, and prost-types are unconditional build dependencies. Remove --features generate from any build scripts.

Serde support

All generated types derive serde::Serialize by default. Deserialization and snake_case renaming are behind optional feature flags (serde-deserialize and serde-snake-case above). Enable them in your Cargo.toml:

Default behavior (no feature flags)

All types derive Serialize only:
This allows JSON serialization for debugging:

With serde-deserialize

All types also derive Deserialize with #[serde(default)], matching protobuf semantics where missing fields use default values:

With serde-snake-case

All types additionally accept snake_case during deserialization. This primarily affects enum and oneof variants (prost generates PascalCase names), while struct fields are already snake_case. Serialization output remains unchanged.
The serde-snake-case feature is primarily useful for WASM bridge scenarios where JavaScript sends snake_case JSON to the Rust backend. For most Rust-only use cases, you only need the default Serialize support.

waproto::tags

The build generates the waproto::tags module from the compiled protobuf descriptor. You get one pub mod per proto message with one pub const FIELD_NAME: u32 = N; per field. Nested messages produce nested modules.
The history-sync wire walkers use these constants internally, and compile-time assert! blocks pin them in the hand-written mirror structs. If whatsapp.proto renumbers a field the consts update automatically on next build; if a field referenced by the walkers is renamed or removed, compilation fails rather than the decoder silently reading the wrong wire data.

Code generation

The build generates protobuf code — build.rs always runs. It reads the committed binary descriptor (src/whatsapp.desc), verifies its SHA-256 against src/whatsapp.desc.sha256, and writes two files into OUT_DIR:
  • whatsapp.rs — full prost-generated structs and enums
  • tags.rswaproto::tags field-number constants (see waproto::tags above)
Neither generated file is committed. prost-build, heck, and prost-types are unconditional build dependencies. To update after modifying whatsapp.proto:
The build aborts with a clear message if the descriptor SHA-256 does not match.
The generate feature flag was removed. Code generation is now always-on and does not require any feature flags. Remove --features generate from any existing build scripts.

Usage Examples

Constructing Messages

Pattern Matching

Media Downloads

See Media Handling for complete examples.

WhatsApp Version

The protobuf definitions are based on:
This version is automatically included in the generated file header.

Relationship with wacore

wacore provides utilities for working with waproto messages:
  • proto_helpers - Conversion between protobuf and internal types
  • download - Downloadable trait for media messages
  • upload - Media encryption for upload
  • messages - Message encryption/decryption
  • send - Message building and sending
Example:

Next Steps

wacore

Platform-agnostic protocol implementation

Sending Messages

Sending and receiving messages

Media Handling

Working with media uploads and downloads

Signal Protocol

End-to-end encryption details