pw_protobuf: Encoder rework

Rewrites the pw_protobuf encoder to be oriented around pw_stream
compatibility.

Improvements:
 * Only the deepest nested encoder can be used at any given moment.
   Using a parent encoder triggers a crash rather than silently
   corrupting data.
 * Nested depth is bounded by scratch buffer size and stack usage rather
   than template arguments.
 * Can write to pw::stream::Writer objects without any temporary buffer.
 * Encoders can be explicitly finalized to allow returning to the parent
   encoder for further modifications without needing to create scopes to
   handle RAII behavior.
 * Proto encode interfaces can standardize on the StreamingEncoder as
   any StreamingEncoder can nest until the temporary buffer is
   exhausted.
 * Better handling of endianness.

Change-Id: I3c50abbf2fe28328a9cb1aa527cf829abe583218
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/40245
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Pigweed-Auto-Submit: Armando Montanez <amontanez@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
10 files changed
tree: f9d2356e2c0855c1a348710271b948d931d034b3
  1. build_overrides/
  2. docker/
  3. docs/
  4. pw_allocator/
  5. pw_analog/
  6. pw_arduino_build/
  7. pw_assert/
  8. pw_assert_basic/
  9. pw_assert_log/
  10. pw_base64/
  11. pw_bloat/
  12. pw_blob_store/
  13. pw_boot_armv7m/
  14. pw_build/
  15. pw_bytes/
  16. pw_checksum/
  17. pw_chrono/
  18. pw_chrono_embos/
  19. pw_chrono_freertos/
  20. pw_chrono_stl/
  21. pw_chrono_threadx/
  22. pw_cli/
  23. pw_containers/
  24. pw_cpu_exception/
  25. pw_cpu_exception_cortex_m/
  26. pw_docgen/
  27. pw_doctor/
  28. pw_env_setup/
  29. pw_fuzzer/
  30. pw_hdlc/
  31. pw_hex_dump/
  32. pw_i2c/
  33. pw_interrupt/
  34. pw_interrupt_cortex_m/
  35. pw_kvs/
  36. pw_libc/
  37. pw_log/
  38. pw_log_basic/
  39. pw_log_multisink/
  40. pw_log_null/
  41. pw_log_rpc/
  42. pw_log_sink/
  43. pw_log_tokenized/
  44. pw_malloc/
  45. pw_malloc_freelist/
  46. pw_metric/
  47. pw_minimal_cpp_stdlib/
  48. pw_module/
  49. pw_multisink/
  50. pw_package/
  51. pw_persistent_ram/
  52. pw_polyfill/
  53. pw_preprocessor/
  54. pw_presubmit/
  55. pw_protobuf/
  56. pw_protobuf_compiler/
  57. pw_random/
  58. pw_result/
  59. pw_ring_buffer/
  60. pw_router/
  61. pw_rpc/
  62. pw_snapshot/
  63. pw_span/
  64. pw_status/
  65. pw_stream/
  66. pw_string/
  67. pw_sync/
  68. pw_sync_baremetal/
  69. pw_sync_embos/
  70. pw_sync_freertos/
  71. pw_sync_stl/
  72. pw_sync_threadx/
  73. pw_sys_io/
  74. pw_sys_io_arduino/
  75. pw_sys_io_baremetal_lm3s6965evb/
  76. pw_sys_io_baremetal_stm32f429/
  77. pw_sys_io_stdio/
  78. pw_target_runner/
  79. pw_thread/
  80. pw_thread_embos/
  81. pw_thread_freertos/
  82. pw_thread_stl/
  83. pw_thread_threadx/
  84. pw_tokenizer/
  85. pw_tool/
  86. pw_toolchain/
  87. pw_trace/
  88. pw_trace_tokenized/
  89. pw_unit_test/
  90. pw_varint/
  91. pw_watch/
  92. pw_web_ui/
  93. targets/
  94. third_party/
  95. .bazelignore
  96. .bazelrc
  97. .clang-format
  98. .eslintrc.json
  99. .gitattributes
  100. .gitignore
  101. .gn
  102. .prettierrc.js
  103. .pylintrc
  104. activate.bat
  105. AUTHORS
  106. bootstrap.bat
  107. bootstrap.sh
  108. BUILD
  109. BUILD.gn
  110. BUILDCONFIG.gn
  111. CMakeLists.txt
  112. LICENSE
  113. modules.gni
  114. OWNERS
  115. package.json
  116. PW_PLUGINS
  117. README.md
  118. tsconfig.json
  119. WORKSPACE
  120. yarn.lock
README.md

See our website: http://pigweed.dev