<commit_before>.. default-domain:: cpp

.. highlight:: sh

.. _chapter-protobuf:

-----------
pw_protobuf
-----------
The protobuf module provides a lightweight interface for encoding and decoding
the Protocol Buffer wire format.

Design
======
Unlike other protobuf libraries, which typically provide in-memory data
structures to represent protobuf messages, ``pw_protobuf`` operates directly on
the wire format and leaves data storage to the user. This has a few benefits.
The primary one is that it allows the library to be incredibly small, with the
encoder and decoder each having a code size of around 1.5K and negligible RAM
usage. Users can choose the tradeoffs most suitable for their product on top of
this core implementation.

``pw_protobuf`` also provides zero-overhead C++ code generation which wraps its
low-level wire format operations with a user-friendly API for processing
specific protobuf messages. The code generation integrates with Pigweed's GN
build system.

Usage
=====
``pw_protobuf`` splits wire format encoding and decoding operations. Links to
the design and APIs of each are listed in below.

See also :ref:`chapter-pw-protobuf-compiler` for details on ``pw_protobuf``'s
build system integration.
<commit_msg>pw_protobuf: Add WIP note to docs<commit_after>.. default-domain:: cpp

.. highlight:: sh

.. _chapter-protobuf:

-----------
pw_protobuf
-----------
The protobuf module provides a lightweight interface for encoding and decoding
the Protocol Buffer wire format.

.. note::

  The protobuf module is a work in progress. Wire format encoding and decoding
  is supported, though the APIs are not final. C++ code generation exists for
  encoding, but not decoding.

Design
======
Unlike other protobuf libraries, which typically provide in-memory data
structures to represent protobuf messages, ``pw_protobuf`` operates directly on
the wire format and leaves data storage to the user. This has a few benefits.
The primary one is that it allows the library to be incredibly small, with the
encoder and decoder each having a code size of around 1.5K and negligible RAM
usage. Users can choose the tradeoffs most suitable for their product on top of
this core implementation.

``pw_protobuf`` also provides zero-overhead C++ code generation which wraps its
low-level wire format operations with a user-friendly API for processing
specific protobuf messages. The code generation integrates with Pigweed's GN
build system.

Usage
=====
``pw_protobuf`` splits wire format encoding and decoding operations. Links to
the design and APIs of each are listed in below.

See also :ref:`chapter-pw-protobuf-compiler` for details on ``pw_protobuf``'s
build system integration.

{'fraction_non_alphanumeric': 0.07410151908114117, 'fraction_numerical': 0.0014820303816228233, 'mean_word_length': 4.346534653465347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4512979', 'n_tokens_mistral': 677, 'n_tokens_neox': 629, 'n_words': 368}