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
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
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.Code generation
The protobuf code is auto-generated but checked into version control. Theprost-build dependency is gated behind the generate feature, so normal builds skip code generation entirely — build.rs is a no-op without this feature. This eliminates the heavy prost-build transitive dependency tree (protoc, tempfile, etc.) from regular compilations, improving build times.
To regenerate after modifying whatsapp.proto:
build.rs which uses prost-build to compile whatsapp.proto into whatsapp.rs.
You only need the
generate feature when you’ve changed the .proto file. The generated whatsapp.rs is committed to the repository, so all other builds use it directly.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