From b131429ba65df7b7bb33ebd7f3a7ce066fa4e7dd Mon Sep 17 00:00:00 2001
From: paulavidas <paulavidas@google.com>
Date: Mon, 2 Sep 2019 02:52:41 -0700
Subject: [PATCH] Change return type of Write from Status to StatusOr<int>.

PiperOrigin-RevId: 266746557
---
 python/cc/BUILD.bazel                    | 2 ++
 python/cc/clif/simple_output_stream.clif | 4 ++--
 python/cc/simple_output_stream.h         | 6 ++++--
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/python/cc/BUILD.bazel b/python/cc/BUILD.bazel
index 95fe24b6a..dde65fd9b 100644
--- a/python/cc/BUILD.bazel
+++ b/python/cc/BUILD.bazel
@@ -18,8 +18,10 @@ cc_library(
 cc_library(
     name = "simple_output_stream",
     hdrs = ["simple_output_stream.h"],
+    include_prefix = "tink/",
     deps = [
         "//cc/util:status",
+        "//cc/util:statusor",
         "@com_google_absl//absl/strings",
     ],
 )
diff --git a/python/cc/clif/simple_output_stream.clif b/python/cc/clif/simple_output_stream.clif
index 211a20581..287e14d24 100644
--- a/python/cc/clif/simple_output_stream.clif
+++ b/python/cc/clif/simple_output_stream.clif
@@ -10,13 +10,13 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from "tink/python/util/clif.h" import *  # Status
+from "tink/python/util/clif.h" import *  # Status, StatusOr
 
 from "tink/python/cc/simple_output_stream.h":
   namespace `crypto::tink`:
     class SimpleOutputStream:
       @virtual
-      def `Write` as write(self, data: bytes) -> Status
+      def `Write` as write(self, data: bytes) -> StatusOr<int>
 
       @virtual
       def `Close` as close(self) -> Status
diff --git a/python/cc/simple_output_stream.h b/python/cc/simple_output_stream.h
index 05c81246b..80db68d82 100644
--- a/python/cc/simple_output_stream.h
+++ b/python/cc/simple_output_stream.h
@@ -17,6 +17,7 @@
 
 #include "absl/strings/string_view.h"
 #include "tink/util/status.h"
+#include "tink/util/statusor.h"
 
 namespace crypto {
 namespace tink {
@@ -25,8 +26,9 @@ namespace tink {
 // from Python to C++ via CLIF and vice versa.
 class SimpleOutputStream {
  public:
-  // Writes 'data' to the underlying stream.
-  virtual util::Status Write(absl::string_view data) = 0;
+  // Writes 'data' to the underlying stream and returns the number of bytes
+  // written, which can be less than the size of 'data'.
+  virtual util::StatusOr<int> Write(absl::string_view data) = 0;
 
   // Closes the underlying stream.
   virtual util::Status Close() = 0;
-- 
GitLab