Skip to main content

MAX_MESSAGE_BYTES

Constant MAX_MESSAGE_BYTES 

Source
pub const MAX_MESSAGE_BYTES: u32 = 0x7FFF_FFFF;
Expand description

Maximum encoded size of a protobuf message: 2 GiB − 1 (0x7FFF_FFFF).

The protobuf specification limits any message — top-level or nested — to 2 GiB. buffa enforces this symmetrically:

  • Decode rejects length-delimited payloads declared larger than this with DecodeError::MessageTooLarge, matching protobuf C++ and Java.
  • Encode refuses to serialize a message whose encoded size would exceed it: the panicking entry points (Message::encode and friends) panic, the try_* twins (Message::try_encode and friends) return EncodeError::MessageTooLarge. Without this check a writer could produce bytes that no conforming decoder — including buffa’s own — will read back.