diff --git a/python/cc/BUILD.bazel b/python/cc/BUILD.bazel index 95fe24b6a155a5d9e48b1319b922e425ad85a8cc..dde65fd9b7fc56e0bdba464d32a4374c8b2f7569 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 211a20581839a663393537be3e2e96f7ac989db5..287e14d2483bd49192a078ccd8accf58ad93b6c7 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 05c81246be99f92c8b06e23b8cf306d681475617..80db68d82d188d20d04b1cf8f605dc4fa8fc1f50 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;