pw_status: Introduce StatusBase and rework Status

StatusBase is a zero-cost CRTP status base class used to define
Status-like objects with custom status codes. A designated code value
represents success (ok()).

This enables richer, domain-specific status semantics while preserving
standard Pigweed error handling conventions, including PW_TRY,
PW_CHECK_OK, and PW_ASSERT_OK.

Custom status types can be defined using the PW_STATUS_TYPE macro or by
subclassing StatusBase directly with CRTP. Custom status types are
constructed from their Code.

pw::Status is reworked to be a concrete final class that inherits from
StatusBase<Status, PW_STATUS_OK>, retaining all canonical helper methods
and implicit pw_Status interop. PW_TRY and PW_CHECK_OK continue to
accept types implicitly convertible to pw::Status.

Change-Id: I33acb7f507f7e7290f0eae45edbc53eff007abb1
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/477645
20 files changed
tree: 3bcdc291b5e1c0d360aa163849791c9cd88a2796
  1. .agents/
  2. .allstar/
  3. .gemini/
  4. .github/
  5. .vscode/
  6. build_overrides/
  7. docker/
  8. docs/
  9. kudzu/
  10. pw_alignment/
  11. pw_allocator/
  12. pw_allocator_zephyr/
  13. pw_analog/
  14. pw_android_toolchain/
  15. pw_arduino_build/
  16. pw_assert/
  17. pw_assert_basic/
  18. pw_assert_fuchsia/
  19. pw_assert_log/
  20. pw_assert_tokenized/
  21. pw_assert_trap/
  22. pw_assert_zephyr/
  23. pw_async/
  24. pw_async2/
  25. pw_async_basic/
  26. pw_async_fuchsia/
  27. pw_atomic/
  28. pw_base64/
  29. pw_bloat/
  30. pw_blob_store/
  31. pw_bluetooth/
  32. pw_bluetooth_hci/
  33. pw_bluetooth_profiles/
  34. pw_bluetooth_proxy/
  35. pw_bluetooth_sapphire/
  36. pw_boot/
  37. pw_boot_cortex_m/
  38. pw_buf/
  39. pw_build/
  40. pw_build_android/
  41. pw_build_info/
  42. pw_build_mcuxpresso/
  43. pw_bytes/
  44. pw_change/
  45. pw_channel/
  46. pw_checksum/
  47. pw_chre/
  48. pw_chrono/
  49. pw_chrono_embos/
  50. pw_chrono_freertos/
  51. pw_chrono_rp2040/
  52. pw_chrono_stl/
  53. pw_chrono_threadx/
  54. pw_chrono_zephyr/
  55. pw_cli/
  56. pw_cli_analytics/
  57. pw_clock_tree/
  58. pw_clock_tree_mcuxpresso/
  59. pw_compilation_testing/
  60. pw_config_loader/
  61. pw_console/
  62. pw_containers/
  63. pw_cpu_exception/
  64. pw_cpu_exception_cortex_m/
  65. pw_cpu_exception_risc_v/
  66. pw_crypto/
  67. pw_digital_io/
  68. pw_digital_io_linux/
  69. pw_digital_io_mcuxpresso/
  70. pw_digital_io_rp2040/
  71. pw_digital_io_zephyr/
  72. pw_display/
  73. pw_dma_mcuxpresso/
  74. pw_docgen/
  75. pw_doctor/
  76. pw_elf/
  77. pw_emu/
  78. pw_enum/
  79. pw_env_setup/
  80. pw_env_setup_zephyr/
  81. pw_file/
  82. pw_flatbuffers/
  83. pw_format/
  84. pw_fortifier/
  85. pw_function/
  86. pw_fuzzer/
  87. pw_ghish/
  88. pw_grpc/
  89. pw_hal/
  90. pw_hdlc/
  91. pw_hex_dump/
  92. pw_hil/
  93. pw_i2c/
  94. pw_i2c_linux/
  95. pw_i2c_mcuxpresso/
  96. pw_i2c_rp2040/
  97. pw_i2c_zephyr/
  98. pw_ide/
  99. pw_interrupt/
  100. pw_interrupt_cortex_m/
  101. pw_interrupt_freertos/
  102. pw_interrupt_zephyr/
  103. pw_intrusive_ptr/
  104. pw_json/
  105. pw_kernel/
  106. pw_kvs/
  107. pw_libc/
  108. pw_libcxx/
  109. pw_log/
  110. pw_log_android/
  111. pw_log_basic/
  112. pw_log_fuchsia/
  113. pw_log_null/
  114. pw_log_rpc/
  115. pw_log_string/
  116. pw_log_tokenized/
  117. pw_log_zephyr/
  118. pw_malloc/
  119. pw_malloc_freelist/
  120. pw_malloc_freertos/
  121. pw_memory/
  122. pw_metric/
  123. pw_module/
  124. pw_multibuf/
  125. pw_multisink/
  126. pw_numeric/
  127. pw_package/
  128. pw_perf_test/
  129. pw_persistent_ram/
  130. pw_polyfill/
  131. pw_preprocessor/
  132. pw_presubmit/
  133. pw_protobuf/
  134. pw_protobuf_compiler/
  135. pw_random/
  136. pw_random_fuchsia/
  137. pw_result/
  138. pw_ring_buffer/
  139. pw_router/
  140. pw_rpc/
  141. pw_rpc2/
  142. pw_rpc_transport/
  143. pw_rust/
  144. pw_sensor/
  145. pw_snapshot/
  146. pw_software_update/
  147. pw_span/
  148. pw_spi/
  149. pw_spi_linux/
  150. pw_spi_mcuxpresso/
  151. pw_spi_rp2040/
  152. pw_spi_zephyr/
  153. pw_status/
  154. pw_stm32cube_build/
  155. pw_stream/
  156. pw_stream_uart_linux/
  157. pw_stream_uart_mcuxpresso/
  158. pw_string/
  159. pw_symbolizer/
  160. pw_sync/
  161. pw_sync_baremetal/
  162. pw_sync_embos/
  163. pw_sync_freertos/
  164. pw_sync_stl/
  165. pw_sync_threadx/
  166. pw_sync_zephyr/
  167. pw_sys_io/
  168. pw_sys_io_ambiq_sdk/
  169. pw_sys_io_arduino/
  170. pw_sys_io_baremetal_lm3s6965evb/
  171. pw_sys_io_baremetal_stm32f429/
  172. pw_sys_io_emcraft_sf2/
  173. pw_sys_io_mcuxpresso/
  174. pw_sys_io_rp2040/
  175. pw_sys_io_stdio/
  176. pw_sys_io_stm32cube/
  177. pw_sys_io_zephyr/
  178. pw_system/
  179. pw_target_runner/
  180. pw_thread/
  181. pw_thread_embos/
  182. pw_thread_freertos/
  183. pw_thread_stl/
  184. pw_thread_threadx/
  185. pw_thread_zephyr/
  186. pw_time/
  187. pw_tls_client/
  188. pw_tls_client_boringssl/
  189. pw_tls_client_mbedtls/
  190. pw_tokenizer/
  191. pw_toolchain/
  192. pw_trace/
  193. pw_trace_tokenized/
  194. pw_transfer/
  195. pw_transport/
  196. pw_uart/
  197. pw_uart_mcuxpresso/
  198. pw_unit_test/
  199. pw_uuid/
  200. pw_varint/
  201. pw_watch/
  202. pw_web/
  203. pw_work_queue/
  204. seed/
  205. targets/
  206. third_party/
  207. zephyr/
  208. .bazelignore
  209. .bazelrc
  210. .bazelversion
  211. .black.toml
  212. .clang-format
  213. .clang-tidy
  214. .git-blame-ignore-revs
  215. .gitattributes
  216. .gitignore
  217. .gn
  218. .mypy.ini
  219. .prettierignore
  220. .prettierrc.cjs
  221. .pw_ide.yaml
  222. .pylintrc
  223. .rgignore
  224. .ruff.toml
  225. activate.bat
  226. AGENTS.md
  227. Android.bp
  228. AUTHORS
  229. bootstrap.bat
  230. bootstrap.fish
  231. bootstrap.sh
  232. BUILD.bazel
  233. BUILD.gn
  234. BUILDCONFIG.gn
  235. CLAUDE.md
  236. CMakeLists.txt
  237. EXTENDED_OWNERS
  238. GEMINI.md
  239. gh
  240. go.mod
  241. go.sum
  242. Kconfig.zephyr
  243. LICENSE
  244. MODULE.bazel
  245. MODULE.bazel.lock
  246. modules.gni
  247. OWNERS
  248. package.json
  249. pigweed.json
  250. PIGWEED_MODULES
  251. pw
  252. README.md
  253. REPO.bazel
  254. rustfmt.toml
  255. tsconfig.json
  256. workflows.json
  257. WORKSPACE_OWNERS
README.md

Pigweed

Pigweed is an open source collection of embedded-targeted libraries–or as we like to call them, modules. These modules are building blocks and infrastructure that enable faster and more reliable development on small-footprint MMU-less 32-bit microcontrollers like the STMicroelectronics STM32L452 or the Nordic nRF52832.

For more information please see our website: https://pigweed.dev/.

Links