aboutsummaryrefslogtreecommitdiff
path: root/pw_sys_io/sys_io.cc
diff options
context:
space:
mode:
authorArmando Montanez <amontanez@google.com>2020-03-02 14:58:59 -0800
committerCQ Bot Account <commit-bot@chromium.org>2020-03-03 18:19:17 +0000
commitf7a5a742abf3aadf74fc527b0afeffe4e346a2b8 (patch)
tree869b217cacf96589faa4b447d8b478da2eafc2cf /pw_sys_io/sys_io.cc
parentba1bb1ff43aab470ce6119aff7140395428eed66 (diff)
downloadpigweed-f7a5a742abf3aadf74fc527b0afeffe4e346a2b8.tar.gz
Rename pw_dumb_io to pw_sys_io
Rename pw_dumb_io facade and backends to use the more deliberate name pw_sys_io moving forward. Change-Id: I968480715967ab8de491856afa1b7692b973ed7e
Diffstat (limited to 'pw_sys_io/sys_io.cc')
-rw-r--r--pw_sys_io/sys_io.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/pw_sys_io/sys_io.cc b/pw_sys_io/sys_io.cc
new file mode 100644
index 000000000..ed0ab5c5a
--- /dev/null
+++ b/pw_sys_io/sys_io.cc
@@ -0,0 +1,39 @@
+// Copyright 2019 The Pigweed Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+#include "pw_sys_io/sys_io.h"
+
+namespace pw::sys_io {
+
+StatusWithSize ReadBytes(span<std::byte> dest) {
+ for (size_t i = 0; i < dest.size_bytes(); ++i) {
+ Status result = ReadByte(&dest[i]);
+ if (!result.ok()) {
+ return StatusWithSize(result, i);
+ }
+ }
+ return StatusWithSize(dest.size_bytes());
+}
+
+StatusWithSize WriteBytes(span<const std::byte> src) {
+ for (size_t i = 0; i < src.size_bytes(); ++i) {
+ Status result = WriteByte(src[i]);
+ if (!result.ok()) {
+ return StatusWithSize(result, i);
+ }
+ }
+ return StatusWithSize(src.size_bytes());
+}
+
+} // namespace pw::sys_io