pw_sys_io: Switch to pw::ByteSpan instead of std::span

Switching pw_sys_io to ByteSpan/ConstByteSpan makes it simpler to
migrate downstream projcets that implement ReadBytes and WriteBytes to
pw::span, since they can switch to ByteSpan/ConstByteSpan and be
automatically migrated.

Change-Id: I14c04806ea97f853f8e84c9f0dc481de94b1fb2a
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/99820
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Ted Pudlik <tpudlik@google.com>
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
diff --git a/pw_sys_io/BUILD.bazel b/pw_sys_io/BUILD.bazel
index cf1ecc3..fdba093 100644
--- a/pw_sys_io/BUILD.bazel
+++ b/pw_sys_io/BUILD.bazel
@@ -27,7 +27,7 @@
     hdrs = ["public/pw_sys_io/sys_io.h"],
     includes = ["public"],
     deps = [
-        "//pw_span",
+        "//pw_bytes",
         "//pw_status",
     ],
 )
@@ -44,11 +44,8 @@
 
 pw_cc_library(
     name = "pw_sys_io",
-    hdrs = ["public/pw_sys_io/sys_io.h"],
     deps = [
         ":facade",
-        "//pw_span",
-        "//pw_status",
         "@pigweed_config//:pw_sys_io_backend",
     ],
 )
diff --git a/pw_sys_io/BUILD.gn b/pw_sys_io/BUILD.gn
index 2b9ff9b..ee2e8f0 100644
--- a/pw_sys_io/BUILD.gn
+++ b/pw_sys_io/BUILD.gn
@@ -27,7 +27,7 @@
   backend = pw_sys_io_BACKEND
   public_configs = [ ":public_include_path" ]
   public_deps = [
-    dir_pw_span,
+    dir_pw_bytes,
     dir_pw_status,
   ]
   public = [ "public/pw_sys_io/sys_io.h" ]
diff --git a/pw_sys_io/CMakeLists.txt b/pw_sys_io/CMakeLists.txt
index 558801f..f3c6be0 100644
--- a/pw_sys_io/CMakeLists.txt
+++ b/pw_sys_io/CMakeLists.txt
@@ -20,8 +20,8 @@
   PUBLIC_INCLUDES
     public
   PUBLIC_DEPS
+    pw_bytes
     pw_status
-    pw_polyfill.span
 )
 
 pw_add_module_library(pw_sys_io.default_putget_bytes
diff --git a/pw_sys_io/public/pw_sys_io/sys_io.h b/pw_sys_io/public/pw_sys_io/sys_io.h
index f93e64a..ddbc273 100644
--- a/pw_sys_io/public/pw_sys_io/sys_io.h
+++ b/pw_sys_io/public/pw_sys_io/sys_io.h
@@ -37,9 +37,9 @@
 
 #include <cstddef>
 #include <cstring>
-#include <span>
 #include <string_view>
 
+#include "pw_bytes/span.h"
 #include "pw_status/status.h"
 #include "pw_status/status_with_size.h"
 
@@ -96,7 +96,7 @@
 // Return status is OkStatus() if the destination span was successfully
 // filled. In all cases, the number of bytes successuflly read to the
 // destination span are returned as part of the StatusWithSize.
-StatusWithSize ReadBytes(std::span<std::byte> dest);
+StatusWithSize ReadBytes(ByteSpan dest);
 
 // Write std::span of bytes out the sys io backend using WriteByte().
 // Implemented by: Facade
@@ -110,6 +110,6 @@
 // Return status is OkStatus() if all the bytes from the source span were
 // successfully written. In all cases, the number of bytes successfully written
 // are returned as part of the StatusWithSize.
-StatusWithSize WriteBytes(std::span<const std::byte> src);
+StatusWithSize WriteBytes(ConstByteSpan src);
 
 }  // namespace pw::sys_io
diff --git a/pw_sys_io/sys_io.cc b/pw_sys_io/sys_io.cc
index 8e013c3..a9f42a2 100644
--- a/pw_sys_io/sys_io.cc
+++ b/pw_sys_io/sys_io.cc
@@ -16,7 +16,7 @@
 
 namespace pw::sys_io {
 
-StatusWithSize ReadBytes(std::span<std::byte> dest) {
+StatusWithSize ReadBytes(ByteSpan dest) {
   for (size_t i = 0; i < dest.size_bytes(); ++i) {
     Status result = ReadByte(&dest[i]);
     if (!result.ok()) {
@@ -26,7 +26,7 @@
   return StatusWithSize(dest.size_bytes());
 }
 
-StatusWithSize WriteBytes(std::span<const std::byte> src) {
+StatusWithSize WriteBytes(ConstByteSpan src) {
   for (size_t i = 0; i < src.size_bytes(); ++i) {
     Status result = WriteByte(src[i]);
     if (!result.ok()) {