pw_thread: Move protos to pw.thread.proto

Moves pw_thread proto files into the pw.thread.proto package to avoid
naming collisions with non-proto types provided by the module.

Requires: pigweed-internal:32463
Change-Id: Ia1cc934aad31eb63e71bb1ba6967f5b2b1646eb6
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/112115
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Commit-Queue: Armando Montanez <amontanez@google.com>
diff --git a/pw_cpu_exception_cortex_m/public/pw_cpu_exception_cortex_m/snapshot.h b/pw_cpu_exception_cortex_m/public/pw_cpu_exception_cortex_m/snapshot.h
index 50ba3a3..2ba59df 100644
--- a/pw_cpu_exception_cortex_m/public/pw_cpu_exception_cortex_m/snapshot.h
+++ b/pw_cpu_exception_cortex_m/public/pw_cpu_exception_cortex_m/snapshot.h
@@ -38,7 +38,7 @@
     const pw_cpu_exception_State& cpu_state,
     uintptr_t stack_low_addr,
     uintptr_t stack_high_addr,
-    thread::SnapshotThreadInfo::StreamEncoder& encoder,
+    thread::proto::SnapshotThreadInfo::StreamEncoder& encoder,
     thread::ProcessThreadStackCallback& thread_stack_callback);
 
 // Captures the main stack thread if active as part of a snapshot based on the
@@ -49,7 +49,7 @@
 Status SnapshotMainStackThread(
     uintptr_t stack_low_addr,
     uintptr_t stack_high_addr,
-    thread::SnapshotThreadInfo::StreamEncoder& encoder,
+    thread::proto::SnapshotThreadInfo::StreamEncoder& encoder,
     thread::ProcessThreadStackCallback& thread_stack_callback);
 
 // Captures the main stack thread if active as part of the cpu register state if
@@ -61,7 +61,7 @@
     const pw_cpu_exception_State* optional_cpu_state,
     uintptr_t stack_low_addr,
     uintptr_t stack_high_addr,
-    thread::SnapshotThreadInfo::StreamEncoder& encoder,
+    thread::proto::SnapshotThreadInfo::StreamEncoder& encoder,
     thread::ProcessThreadStackCallback& thread_stack_callback) {
   if (optional_cpu_state != nullptr) {
     return SnapshotMainStackThread(*optional_cpu_state,
diff --git a/pw_cpu_exception_cortex_m/snapshot.cc b/pw_cpu_exception_cortex_m/snapshot.cc
index ca3db2c..8850f7a 100644
--- a/pw_cpu_exception_cortex_m/snapshot.cc
+++ b/pw_cpu_exception_cortex_m/snapshot.cc
@@ -38,21 +38,22 @@
     uintptr_t stack_low_addr,
     uintptr_t stack_high_addr,
     uintptr_t stack_pointer,
-    thread::SnapshotThreadInfo::StreamEncoder& snapshot_encoder,
+    thread::proto::SnapshotThreadInfo::StreamEncoder& snapshot_encoder,
     thread::ProcessThreadStackCallback& thread_stack_callback) {
-  thread::Thread::StreamEncoder encoder = snapshot_encoder.GetThreadsEncoder();
+  thread::proto::Thread::StreamEncoder encoder =
+      snapshot_encoder.GetThreadsEncoder();
 
   const char* thread_name;
-  thread::ThreadState::Enum thread_state;
+  thread::proto::ThreadState::Enum thread_state;
   if (mode == ProcessorMode::kHandlerMode) {
     thread_name = kMainStackHandlerModeName;
     PW_LOG_DEBUG("Capturing thread info for Main Stack (Handler Mode)");
-    thread_state = thread::ThreadState::Enum::INTERRUPT_HANDLER;
+    thread_state = thread::proto::ThreadState::Enum::INTERRUPT_HANDLER;
     PW_LOG_DEBUG("Thread state: INTERRUPT_HANDLER");
   } else {  // mode == ProcessorMode::kThreadMode
     thread_name = kMainStackThreadModeName;
     PW_LOG_DEBUG("Capturing thread info for Main Stack (Thread Mode)");
-    thread_state = thread::ThreadState::Enum::RUNNING;
+    thread_state = thread::proto::ThreadState::Enum::RUNNING;
     PW_LOG_DEBUG("Thread state: RUNNING");
   }
   encoder.WriteState(thread_state);
@@ -84,7 +85,7 @@
 Status SnapshotMainStackThread(
     uintptr_t stack_low_addr,
     uintptr_t stack_high_addr,
-    thread::SnapshotThreadInfo::StreamEncoder& encoder,
+    thread::proto::SnapshotThreadInfo::StreamEncoder& encoder,
     thread::ProcessThreadStackCallback& thread_stack_callback) {
   uintptr_t stack_pointer;
   asm volatile("mrs %0, msp\n" : "=r"(stack_pointer));
@@ -130,7 +131,7 @@
     const pw_cpu_exception_State& cpu_state,
     uintptr_t stack_low_addr,
     uintptr_t stack_high_addr,
-    thread::SnapshotThreadInfo::StreamEncoder& encoder,
+    thread::proto::SnapshotThreadInfo::StreamEncoder& encoder,
     thread::ProcessThreadStackCallback& thread_stack_callback) {
   if (!MainStackActive(cpu_state)) {
     return OkStatus();  // Main stack wasn't active, nothing to capture.
diff --git a/pw_snapshot/pw_snapshot_protos/snapshot.proto b/pw_snapshot/pw_snapshot_protos/snapshot.proto
index 789400c..62b33ed 100644
--- a/pw_snapshot/pw_snapshot_protos/snapshot.proto
+++ b/pw_snapshot/pw_snapshot_protos/snapshot.proto
@@ -68,7 +68,7 @@
   // entries added to it during a decode.
   map<string, string> tags = 17;
 
-  repeated pw.thread.Thread threads = 18;
+  repeated pw.thread.proto.Thread threads = 18;
 
   // If a device has multiple cores, it may be useful to collect an associated
   // snapshot for attached cores when a snapshot collection is triggered on one
diff --git a/pw_system/thread_snapshot_service.cc b/pw_system/thread_snapshot_service.cc
index 3f40492..fcc4c2a 100644
--- a/pw_system/thread_snapshot_service.cc
+++ b/pw_system/thread_snapshot_service.cc
@@ -19,7 +19,7 @@
 namespace pw::system {
 namespace {
 
-thread::ThreadSnapshotServiceBuilder<> system_thread_snapshot_service;
+thread::proto::ThreadSnapshotServiceBuffer<> system_thread_snapshot_service;
 
 }  // namespace
 
diff --git a/pw_thread/docs.rst b/pw_thread/docs.rst
index d9c17fe..31b173b 100644
--- a/pw_thread/docs.rst
+++ b/pw_thread/docs.rst
@@ -490,10 +490,10 @@
 =================
 To expose a ``ThreadSnapshotService`` in your application, do the following:
 
-1. Create an instance of ``pw::thread::ThreadSnapshotServiceBuilder``. This is a
-   template class that takes in the number of threads as at template, or
-   defaults this value to ``PW_THREAD_MAXIMUM_THREADS`` if no argument is
-   provided.
+1. Create an instance of ``pw::thread::proto::ThreadSnapshotServiceBuffer``.
+   This template takes the number of expected threads, and uses it to properly
+   size buffers required for a ``ThreadSnapshotService``. If no thread count
+   argument is provided, this defaults to ``PW_THREAD_MAXIMUM_THREADS``.
 2. Register the service with your RPC server.
 
 For example:
@@ -504,13 +504,14 @@
    #include "pw_thread/thread_snapshot_service.h"
 
    // Note: You must customize the RPC server setup; see pw_rpc.
-   Channel channels[] = {
-    Channel::Create<1>(&uart_output),
+   pw::rpc::Channel channels[] = {
+    pw::rpc::Channel::Create<1>(&uart_output),
    };
    Server server(channels);
 
   // Thread snapshot service builder instance.
-  thread::ThreadSnapshotServiceBuilder</*num threads*/> thread_snapshot_service;
+  pw::thread::proto::ThreadSnapshotServiceBuffer</*num threads*/>
+      thread_snapshot_service;
 
    void RegisterServices() {
      server.RegisterService(thread_snapshot_service);
diff --git a/pw_thread/public/pw_thread/snapshot.h b/pw_thread/public/pw_thread/snapshot.h
index 34334f7..c2502ae 100644
--- a/pw_thread/public/pw_thread/snapshot.h
+++ b/pw_thread/public/pw_thread/snapshot.h
@@ -28,7 +28,7 @@
 // field. This should encode either raw_backtrace or raw_stack to the provided
 // Thread stream encoder.
 using ProcessThreadStackCallback =
-    Function<Status(Thread::StreamEncoder&, ConstByteSpan)>;
+    Function<Status(proto::Thread::StreamEncoder&, ConstByteSpan)>;
 
 struct StackContext {
   std::string_view thread_name;
@@ -48,7 +48,7 @@
 //     stack_end_pointer
 //     stack_pointer
 Status SnapshotStack(const StackContext& stack,
-                     Thread::StreamEncoder& encoder,
+                     proto::Thread::StreamEncoder& encoder,
                      const ProcessThreadStackCallback& thread_stack_callback);
 
 }  // namespace pw::thread
diff --git a/pw_thread/public/pw_thread/thread_snapshot_service.h b/pw_thread/public/pw_thread/thread_snapshot_service.h
index b8926f9..e18178a 100644
--- a/pw_thread/public/pw_thread/thread_snapshot_service.h
+++ b/pw_thread/public/pw_thread/thread_snapshot_service.h
@@ -22,16 +22,17 @@
 #include "pw_thread_protos/thread_snapshot_service.pwpb.h"
 #include "pw_thread_protos/thread_snapshot_service.raw_rpc.pb.h"
 
-namespace pw::thread {
+namespace pw::thread::proto {
 
-Status ProtoEncodeThreadInfo(SnapshotThreadInfo::MemoryEncoder& encoder,
+Status ProtoEncodeThreadInfo(proto::SnapshotThreadInfo::StreamEncoder& encoder,
                              const ThreadInfo& thread_info);
 
 // Calculates encoded buffer size based on code gen constants.
 constexpr size_t RequiredServiceBufferSize(
     size_t num_threads = PW_THREAD_MAXIMUM_THREADS) {
   constexpr size_t kSizeOfResponse =
-      SnapshotThreadInfo::kMaxEncodedSizeBytes + Thread::kMaxEncodedSizeBytes;
+      proto::SnapshotThreadInfo::kMaxEncodedSizeBytes +
+      Thread::kMaxEncodedSizeBytes;
   return kSizeOfResponse * num_threads;
 }
 
@@ -69,17 +70,16 @@
 // A ThreadSnapshotService that allocates required buffers based on the
 // number of running threads on a device.
 template <size_t kNumThreads = PW_THREAD_MAXIMUM_THREADS>
-class ThreadSnapshotServiceBuilder : public ThreadSnapshotService {
+class ThreadSnapshotServiceBuffer : public ThreadSnapshotService {
  public:
-  ThreadSnapshotServiceBuilder()
+  ThreadSnapshotServiceBuffer()
       : ThreadSnapshotService(encode_buffer_, thread_proto_indices_) {}
 
  private:
-  std::array<std::byte, thread::RequiredServiceBufferSize(kNumThreads)>
-      encode_buffer_;
+  std::array<std::byte, RequiredServiceBufferSize(kNumThreads)> encode_buffer_;
   // + 1 is needed to account for extra index that comes with the first
   // submessage start or the last submessage end.
   Vector<size_t, kNumThreads + 1> thread_proto_indices_;
 };
 
-}  // namespace pw::thread
+}  // namespace pw::thread::proto
diff --git a/pw_thread/pw_thread_private/thread_snapshot_service.h b/pw_thread/pw_thread_private/thread_snapshot_service.h
index d217513..330c7e6 100644
--- a/pw_thread/pw_thread_private/thread_snapshot_service.h
+++ b/pw_thread/pw_thread_private/thread_snapshot_service.h
@@ -17,11 +17,11 @@
 #include "pw_span/span.h"
 #include "pw_status/status.h"
 
-namespace pw::thread {
+namespace pw::thread::proto {
 
 void ErrorLog(Status status);
 
 Status DecodeThreadName(ConstByteSpan serialized_path,
                         ConstByteSpan& thread_name);
 
-}  // namespace pw::thread
+}  // namespace pw::thread::proto
diff --git a/pw_thread/pw_thread_protos/thread.proto b/pw_thread/pw_thread_protos/thread.proto
index bcfbb09..d49f603 100644
--- a/pw_thread/pw_thread_protos/thread.proto
+++ b/pw_thread/pw_thread_protos/thread.proto
@@ -13,7 +13,7 @@
 // the License.
 syntax = "proto3";
 
-package pw.thread;
+package pw.thread.proto;
 
 import "pw_tokenizer/proto/options.proto";
 
@@ -106,5 +106,5 @@
 // This message overlays the pw.snapshot.Snapshot proto. It's valid to encode
 // this message to the same sink that a Snapshot proto is being written to.
 message SnapshotThreadInfo {
-  repeated pw.thread.Thread threads = 18;
+  repeated pw.thread.proto.Thread threads = 18;
 }
diff --git a/pw_thread/pw_thread_protos/thread_snapshot_service.proto b/pw_thread/pw_thread_protos/thread_snapshot_service.proto
index 136a9a7..ef108b2 100644
--- a/pw_thread/pw_thread_protos/thread_snapshot_service.proto
+++ b/pw_thread/pw_thread_protos/thread_snapshot_service.proto
@@ -13,7 +13,7 @@
 // the License.
 syntax = "proto3";
 
-package pw.thread;
+package pw.thread.proto;
 
 import "pw_thread_protos/thread.proto";
 
diff --git a/pw_thread/snapshot.cc b/pw_thread/snapshot.cc
index 4754420..76df4bc 100644
--- a/pw_thread/snapshot.cc
+++ b/pw_thread/snapshot.cc
@@ -30,7 +30,7 @@
 namespace pw::thread {
 
 Status SnapshotStack(const StackContext& stack,
-                     Thread::StreamEncoder& encoder,
+                     proto::Thread::StreamEncoder& encoder,
                      const ProcessThreadStackCallback& thread_stack_callback) {
   // TODO(b/234890430): Add support for ascending stacks.
   encoder.WriteStackStartPointer(stack.stack_high_addr).IgnoreError();
diff --git a/pw_thread/thread_snapshot_service.cc b/pw_thread/thread_snapshot_service.cc
index 02114d0..c6a4450 100644
--- a/pw_thread/thread_snapshot_service.cc
+++ b/pw_thread/thread_snapshot_service.cc
@@ -27,9 +27,9 @@
 #include "pw_thread_protos/thread.pwpb.h"
 #include "pw_thread_protos/thread_snapshot_service.pwpb.h"
 
-namespace pw::thread {
+namespace pw::thread::proto {
 
-Status ProtoEncodeThreadInfo(SnapshotThreadInfo::MemoryEncoder& encoder,
+Status ProtoEncodeThreadInfo(SnapshotThreadInfo::StreamEncoder& encoder,
                              const ThreadInfo& thread_info) {
   // Grab the next available Thread slot to write to in the response.
   Thread::StreamEncoder proto_encoder = encoder.GetThreadsEncoder();
@@ -189,4 +189,4 @@
   }
 }
 
-}  // namespace pw::thread
+}  // namespace pw::thread::proto
diff --git a/pw_thread/thread_snapshot_service_test.cc b/pw_thread/thread_snapshot_service_test.cc
index 375d1e7..182068c 100644
--- a/pw_thread/thread_snapshot_service_test.cc
+++ b/pw_thread/thread_snapshot_service_test.cc
@@ -24,7 +24,7 @@
 #include "pw_thread_protos/thread.pwpb.h"
 #include "pw_thread_protos/thread_snapshot_service.pwpb.h"
 
-namespace pw::thread::freertos {
+namespace pw::thread::proto {
 namespace {
 
 // Iterates through each proto encoded thread in the buffer.
@@ -33,7 +33,7 @@
   protobuf::Decoder decoder(serialized_thread_buffer);
   while (decoder.Next().ok()) {
     switch (decoder.FieldNumber()) {
-      case static_cast<uint32_t>(SnapshotThreadInfo::Fields::THREADS): {
+      case static_cast<uint32_t>(proto::SnapshotThreadInfo::Fields::THREADS): {
         ConstByteSpan thread_buffer;
         EXPECT_EQ(OkStatus(), decoder.ReadBytes(&thread_buffer));
         ConstByteSpan encoded_name;
@@ -78,7 +78,7 @@
 TEST(ThreadSnapshotService, DecodeSingleThreadInfoObject) {
   std::array<std::byte, RequiredServiceBufferSize(1)> encode_buffer;
 
-  SnapshotThreadInfo::MemoryEncoder encoder(encode_buffer);
+  proto::SnapshotThreadInfo::MemoryEncoder encoder(encode_buffer);
 
   ConstByteSpan name = bytes::String("MyThread\0");
   ThreadInfo thread_info = CreateThreadInfoObject(
@@ -99,7 +99,7 @@
 TEST(ThreadSnapshotService, DecodeMultipleThreadInfoObjects) {
   std::array<std::byte, RequiredServiceBufferSize(3)> encode_buffer;
 
-  SnapshotThreadInfo::MemoryEncoder encoder(encode_buffer);
+  proto::SnapshotThreadInfo::MemoryEncoder encoder(encode_buffer);
 
   ConstByteSpan name = bytes::String("MyThread1\0");
   ThreadInfo thread_info_1 =
@@ -139,7 +139,7 @@
 TEST(ThreadSnapshotService, DefaultBufferSize) {
   static std::array<std::byte, RequiredServiceBufferSize()> encode_buffer;
 
-  SnapshotThreadInfo::MemoryEncoder encoder(encode_buffer);
+  proto::SnapshotThreadInfo::MemoryEncoder encoder(encode_buffer);
 
   ConstByteSpan name = bytes::String("MyThread\0");
   std::optional<uintptr_t> example_addr =
@@ -160,7 +160,7 @@
 TEST(ThreadSnapshotService, FailedPrecondition) {
   static std::array<std::byte, RequiredServiceBufferSize(1)> encode_buffer;
 
-  SnapshotThreadInfo::MemoryEncoder encoder(encode_buffer);
+  proto::SnapshotThreadInfo::MemoryEncoder encoder(encode_buffer);
 
   ThreadInfo thread_info_no_name = CreateThreadInfoObject(
       std::nullopt,
@@ -186,7 +186,7 @@
 TEST(ThreadSnapshotService, Unimplemented) {
   static std::array<std::byte, RequiredServiceBufferSize(1)> encode_buffer;
 
-  SnapshotThreadInfo::MemoryEncoder encoder(encode_buffer);
+  proto::SnapshotThreadInfo::MemoryEncoder encoder(encode_buffer);
 
   ConstByteSpan name = bytes::String("MyThread\0");
   ThreadInfo thread_info_no_peak_addr =
@@ -203,4 +203,4 @@
 }
 
 }  // namespace
-}  // namespace pw::thread::freertos
+}  // namespace pw::thread::proto
diff --git a/pw_thread_embos/docs.rst b/pw_thread_embos/docs.rst
index 0cb1cad..b1fb32b 100644
--- a/pw_thread_embos/docs.rst
+++ b/pw_thread_embos/docs.rst
@@ -199,7 +199,7 @@
   void* stack_ptr = 0;
   asm volatile("mrs %0, psp\n" : "=r"(stack_ptr));
   pw::thread::ProcessThreadStackCallback cb =
-      [](pw::thread::Thread::StreamEncoder& encoder,
+      [](pw::thread::proto::Thread::StreamEncoder& encoder,
          pw::ConstByteSpan stack) -> pw::Status {
     return encoder.WriteRawStack(stack);
   };
@@ -207,10 +207,11 @@
                                     snapshot_encoder, cb);
 
 ``SnapshotThreads()`` wraps the singular thread capture to instead captures
-all created threads to a ``pw::thread::SnapshotThreadInfo`` message. This proto
-message overlays a snapshot, so it is safe to static cast a
+all created threads to a ``pw::thread::proto::SnapshotThreadInfo`` message.
+This proto message overlays a snapshot, so it is safe to static cast a
 ``pw::snapshot::Snapshot::StreamEncoder`` to a
-``pw::thread::SnapshotThreadInfo::StreamEncoder`` when calling this function.
+``pw::thread::proto::SnapshotThreadInfo::StreamEncoder`` when calling this
+function.
 
 Thread Name Capture
 -------------------
diff --git a/pw_thread_embos/public/pw_thread_embos/snapshot.h b/pw_thread_embos/public/pw_thread_embos/snapshot.h
index 75b8adf..8fabec4 100644
--- a/pw_thread_embos/public/pw_thread_embos/snapshot.h
+++ b/pw_thread_embos/public/pw_thread_embos/snapshot.h
@@ -31,7 +31,7 @@
 //    void* stack_ptr = 0;
 //    asm volatile("mrs %0, psp\n" : "=r"(stack_ptr));
 //    pw::thread::ProcessThreadStackCallback cb =
-//        [](pw::thread::Thread::StreamEncoder& encoder,
+//        [](pw::thread::proto::Thread::StreamEncoder& encoder,
 //           pw::ConstByteSpan stack) -> pw::Status {
 //      return encoder.WriteRawStack(stack);
 //    };
@@ -40,7 +40,7 @@
 // Warning: This is only safe to use when interrupts and the scheduler are
 // disabled!
 Status SnapshotThreads(void* running_thread_stack_pointer,
-                       SnapshotThreadInfo::StreamEncoder& encoder,
+                       proto::SnapshotThreadInfo::StreamEncoder& encoder,
                        ProcessThreadStackCallback& thread_stack_callback);
 
 // Captures only the provided thread handle as a pw::thread::Thread proto
@@ -68,7 +68,7 @@
 // disabled!
 Status SnapshotThread(const OS_TASK& thread,
                       void* running_thread_stack_pointer,
-                      Thread::StreamEncoder& encoder,
+                      proto::Thread::StreamEncoder& encoder,
                       ProcessThreadStackCallback& thread_stack_callback);
 
 }  // namespace pw::thread::embos
diff --git a/pw_thread_embos/snapshot.cc b/pw_thread_embos/snapshot.cc
index 55cb241..966d56d 100644
--- a/pw_thread_embos/snapshot.cc
+++ b/pw_thread_embos/snapshot.cc
@@ -37,10 +37,11 @@
   return OS_GetpCurrentTask() == &thread;
 }
 
-void CaptureThreadState(const OS_TASK& thread, Thread::StreamEncoder& encoder) {
+void CaptureThreadState(const OS_TASK& thread,
+                        proto::Thread::StreamEncoder& encoder) {
   if (ThreadIsRunning(thread)) {
     PW_LOG_DEBUG("Thread state: RUNNING");
-    encoder.WriteState(ThreadState::Enum::RUNNING);
+    encoder.WriteState(proto::ThreadState::Enum::RUNNING);
     return;
   }
 
@@ -61,24 +62,24 @@
 
   if ((thread.Stat & 0x3) != 0) {
     PW_LOG_DEBUG("Thread state: SUSPENDED");
-    encoder.WriteState(ThreadState::Enum::SUSPENDED);
+    encoder.WriteState(proto::ThreadState::Enum::SUSPENDED);
   } else if ((thread.Stat & 0xf8) == 0) {
     PW_LOG_DEBUG("Thread state: READY");
-    encoder.WriteState(ThreadState::Enum::READY);
+    encoder.WriteState(proto::ThreadState::Enum::READY);
   } else {
     PW_LOG_DEBUG("Thread state: BLOCKED");
-    encoder.WriteState(ThreadState::Enum::BLOCKED);
+    encoder.WriteState(proto::ThreadState::Enum::BLOCKED);
   }
 }
 
 }  // namespace
 
 Status SnapshotThreads(void* running_thread_stack_pointer,
-                       SnapshotThreadInfo::StreamEncoder& encoder,
+                       proto::SnapshotThreadInfo::StreamEncoder& encoder,
                        ProcessThreadStackCallback& stack_dumper) {
   struct {
     void* running_thread_stack_pointer;
-    SnapshotThreadInfo::StreamEncoder* encoder;
+    proto::SnapshotThreadInfo::StreamEncoder* encoder;
     ProcessThreadStackCallback* stack_dumper;
     Status thread_capture_status;
   } ctx;
@@ -87,7 +88,8 @@
   ctx.stack_dumper = &stack_dumper;
 
   ThreadCallback thread_capture_cb([&ctx](const OS_TASK& thread) -> bool {
-    Thread::StreamEncoder thread_encoder = ctx.encoder->GetThreadsEncoder();
+    proto::Thread::StreamEncoder thread_encoder =
+        ctx.encoder->GetThreadsEncoder();
     ctx.thread_capture_status.Update(
         SnapshotThread(thread,
                        ctx.running_thread_stack_pointer,
@@ -108,7 +110,7 @@
 
 Status SnapshotThread(const OS_TASK& thread,
                       void* running_thread_stack_pointer,
-                      Thread::StreamEncoder& encoder,
+                      proto::Thread::StreamEncoder& encoder,
                       ProcessThreadStackCallback& thread_stack_callback) {
 #if OS_TRACKNAME
   PW_LOG_DEBUG("Capturing thread info for %s", thread.Name);
diff --git a/pw_thread_freertos/docs.rst b/pw_thread_freertos/docs.rst
index e3f0aa7..7bcaf3e 100644
--- a/pw_thread_freertos/docs.rst
+++ b/pw_thread_freertos/docs.rst
@@ -254,7 +254,7 @@
   void* stack_ptr = 0;
   asm volatile("mrs %0, psp\n" : "=r"(stack_ptr));
   pw::thread::ProcessThreadStackCallback cb =
-      [](pw::thread::Thread::StreamEncoder& encoder,
+      [](pw::thread::proto::Thread::StreamEncoder& encoder,
          pw::ConstByteSpan stack) -> pw::Status {
     return encoder.WriteRawStack(stack);
   };
@@ -262,11 +262,12 @@
                                       snapshot_encoder, cb);
 
 ``SnapshotThreads()`` wraps the singular thread capture to instead captures
-all created threads to a ``pw::thread::SnapshotThreadInfo`` message which also
-captures the thread state for you. This proto
+all created threads to a ``pw::thread::proto::SnapshotThreadInfo`` message
+which also captures the thread state for you. This proto
 message overlays a snapshot, so it is safe to static cast a
 ``pw::snapshot::Snapshot::StreamEncoder`` to a
-``pw::thread::SnapshotThreadInfo::StreamEncoder`` when calling this function.
+``pw::thread::proto::SnapshotThreadInfo::StreamEncoder`` when calling this
+function.
 
 .. Note:: ``SnapshotThreads()`` is only safe to use this while the scheduler and
    interrupts are disabled as it relies on ``ForEachThread()``.
diff --git a/pw_thread_freertos/public/pw_thread_freertos/snapshot.h b/pw_thread_freertos/public/pw_thread_freertos/snapshot.h
index 4563d24..d05b928 100644
--- a/pw_thread_freertos/public/pw_thread_freertos/snapshot.h
+++ b/pw_thread_freertos/public/pw_thread_freertos/snapshot.h
@@ -37,7 +37,7 @@
 //    void* stack_ptr = 0;
 //    asm volatile("mrs %0, psp\n" : "=r"(stack_ptr));
 //    pw::thread::ProcessThreadStackCallback cb =
-//        [](pw::thread::Thread::StreamEncoder& encoder,
+//        [](pw::thread::proto::Thread::StreamEncoder& encoder,
 //           pw::ConstByteSpan stack) -> pw::Status {
 //      return encoder.WriteRawStack(stack);
 //    };
@@ -47,7 +47,7 @@
 // Warning: This is only safe to use when the scheduler and interrupts are
 // disabled.
 Status SnapshotThreads(void* running_thread_stack_pointer,
-                       SnapshotThreadInfo::StreamEncoder& encoder,
+                       proto::SnapshotThreadInfo::StreamEncoder& encoder,
                        ProcessThreadStackCallback& thread_stack_callback);
 
 // Captures only the provided thread handle as a pw::thread::Thread proto
@@ -75,7 +75,7 @@
 Status SnapshotThread(TaskHandle_t thread,
                       eTaskState thread_state,
                       void* running_thread_stack_pointer,
-                      Thread::StreamEncoder& encoder,
+                      proto::Thread::StreamEncoder& encoder,
                       ProcessThreadStackCallback& thread_stack_callback);
 
 }  // namespace pw::thread::freertos
diff --git a/pw_thread_freertos/snapshot.cc b/pw_thread_freertos/snapshot.cc
index 8d19f7f..7306235 100644
--- a/pw_thread_freertos/snapshot.cc
+++ b/pw_thread_freertos/snapshot.cc
@@ -44,37 +44,37 @@
         // (INCLUDE_uxTaskGetStackHighWaterMark == 1))
 
 void CaptureThreadState(eTaskState thread_state,
-                        Thread::StreamEncoder& encoder) {
+                        proto::Thread::StreamEncoder& encoder) {
   switch (thread_state) {
     case eRunning:
       PW_LOG_DEBUG("Thread state: RUNNING");
-      encoder.WriteState(ThreadState::Enum::RUNNING).IgnoreError();
+      encoder.WriteState(proto::ThreadState::Enum::RUNNING).IgnoreError();
       return;
 
     case eReady:
       PW_LOG_DEBUG("Thread state: READY");
-      encoder.WriteState(ThreadState::Enum::READY).IgnoreError();
+      encoder.WriteState(proto::ThreadState::Enum::READY).IgnoreError();
       return;
 
     case eBlocked:
       PW_LOG_DEBUG("Thread state: BLOCKED");
-      encoder.WriteState(ThreadState::Enum::BLOCKED).IgnoreError();
+      encoder.WriteState(proto::ThreadState::Enum::BLOCKED).IgnoreError();
       return;
 
     case eSuspended:
       PW_LOG_DEBUG("Thread state: SUSPENDED");
-      encoder.WriteState(ThreadState::Enum::SUSPENDED).IgnoreError();
+      encoder.WriteState(proto::ThreadState::Enum::SUSPENDED).IgnoreError();
       return;
 
     case eDeleted:
       PW_LOG_DEBUG("Thread state: INACTIVE");
-      encoder.WriteState(ThreadState::Enum::INACTIVE).IgnoreError();
+      encoder.WriteState(proto::ThreadState::Enum::INACTIVE).IgnoreError();
       return;
 
     case eInvalid:
     default:
       PW_LOG_DEBUG("Thread state: UNKNOWN");
-      encoder.WriteState(ThreadState::Enum::UNKNOWN).IgnoreError();
+      encoder.WriteState(proto::ThreadState::Enum::UNKNOWN).IgnoreError();
       return;
   }
 }
@@ -82,11 +82,11 @@
 }  // namespace
 
 Status SnapshotThreads(void* running_thread_stack_pointer,
-                       SnapshotThreadInfo::StreamEncoder& encoder,
+                       proto::SnapshotThreadInfo::StreamEncoder& encoder,
                        ProcessThreadStackCallback& stack_dumper) {
   struct {
     void* running_thread_stack_pointer;
-    SnapshotThreadInfo::StreamEncoder* encoder;
+    proto::SnapshotThreadInfo::StreamEncoder* encoder;
     ProcessThreadStackCallback* stack_dumper;
     Status thread_capture_status;
   } ctx;
@@ -97,7 +97,8 @@
 
   ThreadCallback thread_capture_cb(
       [&ctx](TaskHandle_t thread, eTaskState thread_state) -> bool {
-        Thread::StreamEncoder thread_encoder = ctx.encoder->GetThreadsEncoder();
+        proto::Thread::StreamEncoder thread_encoder =
+            ctx.encoder->GetThreadsEncoder();
         ctx.thread_capture_status.Update(
             SnapshotThread(thread,
                            thread_state,
@@ -118,7 +119,7 @@
     TaskHandle_t thread,
     eTaskState thread_state,
     void* running_thread_stack_pointer,
-    Thread::StreamEncoder& encoder,
+    proto::Thread::StreamEncoder& encoder,
     [[maybe_unused]] ProcessThreadStackCallback& thread_stack_callback) {
   const tskTCB& tcb = *reinterpret_cast<tskTCB*>(thread);
 
diff --git a/pw_thread_threadx/docs.rst b/pw_thread_threadx/docs.rst
index 7a2a90f..026ed2b 100644
--- a/pw_thread_threadx/docs.rst
+++ b/pw_thread_threadx/docs.rst
@@ -240,7 +240,7 @@
   void* stack_ptr = 0;
   asm volatile("mrs %0, psp\n" : "=r"(stack_ptr));
   pw::thread::ProcessThreadStackCallback cb =
-      [](pw::thread::Thread::StreamEncoder& encoder,
+      [](pw::thread::proto::Thread::StreamEncoder& encoder,
          pw::ConstByteSpan stack) -> pw::Status {
     return encoder.WriteRawStack(stack);
   };
@@ -248,7 +248,8 @@
                                       snapshot_encoder, cb);
 
 ``SnapshotThreads()`` wraps the singular thread capture to instead captures
-all created threads to a ``pw::thread::SnapshotThreadInfo`` message. This proto
-message overlays a snapshot, so it is safe to static cast a
+all created threads to a ``pw::thread::proto::SnapshotThreadInfo`` message.
+This proto message overlays a snapshot, so it is safe to static cast a
 ``pw::snapshot::Snapshot::StreamEncoder`` to a
-``pw::thread::SnapshotThreadInfo::StreamEncoder`` when calling this function.
+``pw::thread::proto::SnapshotThreadInfo::StreamEncoder`` when calling this
+function.
diff --git a/pw_thread_threadx/public/pw_thread_threadx/snapshot.h b/pw_thread_threadx/public/pw_thread_threadx/snapshot.h
index 1845b53..1b82bc7 100644
--- a/pw_thread_threadx/public/pw_thread_threadx/snapshot.h
+++ b/pw_thread_threadx/public/pw_thread_threadx/snapshot.h
@@ -31,7 +31,7 @@
 //    void* stack_ptr = 0;
 //    asm volatile("mrs %0, psp\n" : "=r"(stack_ptr));
 //    pw::thread::ProcessThreadStackCallback cb =
-//        [](pw::thread::Thread::StreamEncoder& encoder,
+//        [](pw::thread::proto::Thread::StreamEncoder& encoder,
 //           pw::ConstByteSpan stack) -> pw::Status {
 //      return encoder.WriteRawStack(stack);
 //    };
@@ -42,7 +42,7 @@
 // disabled!
 // Warning: SMP ports are not yet supported.
 Status SnapshotThreads(void* running_thread_stack_pointer,
-                       SnapshotThreadInfo::StreamEncoder& encoder,
+                       proto::SnapshotThreadInfo::StreamEncoder& encoder,
                        ProcessThreadStackCallback& thread_stack_callback);
 
 // Captures only the provided thread handle as a pw::thread::Thread proto
@@ -68,7 +68,7 @@
 // Warning: SMP ports are not yet supported.
 Status SnapshotThread(const TX_THREAD& thread,
                       void* running_thread_stack_pointer,
-                      Thread::StreamEncoder& encoder,
+                      proto::Thread::StreamEncoder& encoder,
                       ProcessThreadStackCallback& thread_stack_callback);
 
 }  // namespace pw::thread::threadx
diff --git a/pw_thread_threadx/snapshot.cc b/pw_thread_threadx/snapshot.cc
index bdde802..8dbb969 100644
--- a/pw_thread_threadx/snapshot.cc
+++ b/pw_thread_threadx/snapshot.cc
@@ -41,27 +41,27 @@
 }
 
 void CaptureThreadState(const TX_THREAD& thread,
-                        Thread::StreamEncoder& encoder) {
+                        proto::Thread::StreamEncoder& encoder) {
   if (ThreadIsRunning(thread)) {
     PW_LOG_DEBUG("Thread state: RUNNING");
-    encoder.WriteState(ThreadState::Enum::RUNNING);
+    encoder.WriteState(proto::ThreadState::Enum::RUNNING);
     return;
   }
 
   switch (thread.tx_thread_state) {
     case TX_READY:
       PW_LOG_DEBUG("Thread state: READY");
-      encoder.WriteState(ThreadState::Enum::READY);
+      encoder.WriteState(proto::ThreadState::Enum::READY);
       break;
     case TX_COMPLETED:
     case TX_TERMINATED:
       PW_LOG_DEBUG("Thread state: INACTIVE");
-      encoder.WriteState(ThreadState::Enum::INACTIVE);
+      encoder.WriteState(proto::ThreadState::Enum::INACTIVE);
       break;
     case TX_SUSPENDED:
     case TX_SLEEP:
       PW_LOG_DEBUG("Thread state: SUSPENDED");
-      encoder.WriteState(ThreadState::Enum::SUSPENDED);
+      encoder.WriteState(proto::ThreadState::Enum::SUSPENDED);
       break;
     case TX_QUEUE_SUSP:
     case TX_SEMAPHORE_SUSP:
@@ -73,22 +73,22 @@
     case TX_TCP_IP:
     case TX_MUTEX_SUSP:
       PW_LOG_DEBUG("Thread state: BLOCKED");
-      encoder.WriteState(ThreadState::Enum::BLOCKED);
+      encoder.WriteState(proto::ThreadState::Enum::BLOCKED);
       break;
     default:
       PW_LOG_DEBUG("Thread state: UNKNOWN");
-      encoder.WriteState(ThreadState::Enum::UNKNOWN);
+      encoder.WriteState(proto::ThreadState::Enum::UNKNOWN);
   }
 }
 
 }  // namespace
 
 Status SnapshotThreads(void* running_thread_stack_pointer,
-                       SnapshotThreadInfo::StreamEncoder& encoder,
+                       proto::SnapshotThreadInfo::StreamEncoder& encoder,
                        ProcessThreadStackCallback& stack_dumper) {
   struct {
     void* running_thread_stack_pointer;
-    SnapshotThreadInfo::StreamEncoder* encoder;
+    proto::SnapshotThreadInfo::StreamEncoder* encoder;
     ProcessThreadStackCallback* stack_dumper;
     Status thread_capture_status;
   } ctx;
@@ -97,7 +97,8 @@
   ctx.stack_dumper = &stack_dumper;
 
   ThreadCallback thread_capture_cb([&ctx](const TX_THREAD& thread) -> bool {
-    Thread::StreamEncoder thread_encoder = ctx.encoder->GetThreadsEncoder();
+    proto::Thread::StreamEncoder thread_encoder =
+        ctx.encoder->GetThreadsEncoder();
     ctx.thread_capture_status.Update(
         SnapshotThread(thread,
                        ctx.running_thread_stack_pointer,
@@ -117,7 +118,7 @@
 
 Status SnapshotThread(const TX_THREAD& thread,
                       void* running_thread_stack_pointer,
-                      Thread::StreamEncoder& encoder,
+                      proto::Thread::StreamEncoder& encoder,
                       ProcessThreadStackCallback& thread_stack_callback) {
   PW_LOG_DEBUG("Capturing thread info for %s", thread.tx_thread_name);
   encoder.WriteName(as_bytes(span(std::string_view(thread.tx_thread_name))));