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
whatsapp.rs and tags.rs to OUT_DIR. Do not commit these files.
Usage
All protobuf types are under thewaproto::whatsapp module:
Key message types
Core message types
Message
The main message container used for all WhatsApp messages.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.DELETE- Delete message for everyoneREVOKE- Revoke sent messageEPHEMERAL_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.associated_child_message (a FutureProofMessage) and linked to the parent via a MessageAssociation:
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 deriveserde::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 deriveSerialize only:
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 thewaproto::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.
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 enumstags.rs—waproto::tagsfield-number constants (see waproto::tags above)
prost-build, heck, and prost-types are unconditional build dependencies.
To update after modifying whatsapp.proto:
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:Relationship with wacore
wacore provides utilities for working with waproto messages:proto_helpers- Conversion between protobuf and internal typesdownload-Downloadabletrait for media messagesupload- Media encryption for uploadmessages- Message encryption/decryptionsend- Message building and sending
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