Generate compressed --bes_output and --resultstore_output files.

This ensures that the --bes_output and --resultstore_output options
can take file paths that ends with .gz and will generate gzip-compressed
files directly. This reduces the size of these build event traces
significantly (e.g. 10x times for a small Fuchsia build).

This also removes a nasty bug where failing to create the output file
would print an error message twice when persistent mode is enabled,
by getting rid of the Fatal() calls, and replacing them with proper
error reporting + returning ExitFailure in NinjaMain::RunBuild().

- Change FileOrGzipOutputStream, BuildEventStreamState and
  ResultStoreStreamState to perform initialization in a dedicated
  Init() method that can report an error, instead of their
  constructors.

- Change FileOrGzipOutputStream to take a file path as input,
  instead of a FILE* pointer.

- Modify protobuf related writing classes to use OutputStream*
  instead of std::ostream* to write their outputs. This requires
  modifying the generator script under misc/fuchsia/bes/.

- Update the --help message to clarify that the build event
  streaming options take file paths relative to the Ninja build
  directory, and support gzip-compression by choosing a filename
  that ends with ".gz".

+ Add the `#undefine OPTIONAL` to resulstore_streamer.cc to avoid
  a Win32 compilation issue.

+ Remove a few un-needed header includes.

+ Add `// clang-format off` comments to the generated files to
  ensure that `git clang-format` does not touch them. This
  makes it easier to re-run the scripts later and verify the
  content of their changes.

Fuchsia-Topic: chrome-tracing
Fuchsia-Topic: build-event-stream

Change-Id: I9183ef5104d108335aa429b340c36d801855a1e7
diff --git a/misc/fuchsia/bes/generate_proto_header.py b/misc/fuchsia/bes/generate_proto_header.py
index 0970eef..153073a 100755
--- a/misc/fuchsia/bes/generate_proto_header.py
+++ b/misc/fuchsia/bes/generate_proto_header.py
@@ -586,7 +586,7 @@
 
         # SerializeToOstream method
         ser_type = "void"
-        ser_sig = "SerializeToOstream(std::ostream* output__) const"
+        ser_sig = "SerializeToOstream(OutputStream* output__) const"
         ser_hdr = self.func_proto(rtype=ser_type, f=ser_sig)
         ser_src = self.func_src(
             classname=classname,
@@ -793,15 +793,18 @@
             f"""
             // This file is auto-generated by {_SCRIPT_BASENAME}, do not edit
 
+            // clang-format off
+
             #ifndef {header_guard}
             #define {header_guard}
 
             #include <inttypes.h>
 
-            #include <iosfwd>
             #include <string>
             #include <vector>
 
+            struct OutputStream;
+
         """
         )
 
@@ -810,10 +813,11 @@
             f"""
             // This file is auto-generated by {_SCRIPT_BASENAME}, do not edit
 
+            // clang-format off
+
             #include "{header_basename}"
 
-            #include <iostream>
-
+            #include "output_stream.h"
             #include "proto.h"
 
         """
diff --git a/src/build_event_stream.pb.cc b/src/build_event_stream.pb.cc
index 39790be..e6c6ca0 100644
--- a/src/build_event_stream.pb.cc
+++ b/src/build_event_stream.pb.cc
@@ -1,9 +1,10 @@
 // This file is auto-generated by generate_proto_header.py, do not edit
 
+// clang-format off
+
 #include "build_event_stream.pb.h"
 
-#include <iostream>
-
+#include "output_stream.h"
 #include "proto.h"
 
 namespace bes {
@@ -14,7 +15,7 @@
   has_value_ = false;
 }
 
-void Any::SerializeToOstream(std::ostream* output__) const {
+void Any::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, type_url_);
   WriteString(output__, 2, value_);
 }
@@ -52,7 +53,7 @@
   nanos_ = static_cast< int32_t >(0);
 }
 
-void Duration::SerializeToOstream(std::ostream* output__) const {
+void Duration::SerializeToOstream(OutputStream* output__) const {
   WriteVarint64(output__, 1, seconds_);
   WriteVarint32SignExtended(output__, 2, nanos_);
 }
@@ -90,7 +91,7 @@
   nanos_ = static_cast< int32_t >(0);
 }
 
-void Timestamp::SerializeToOstream(std::ostream* output__) const {
+void Timestamp::SerializeToOstream(OutputStream* output__) const {
   WriteVarint64(output__, 1, seconds_);
   WriteVarint32SignExtended(output__, 2, nanos_);
 }
@@ -137,7 +138,7 @@
   package_overhead_ = static_cast< uint64_t >(0);
 }
 
-void PackageLoadMetrics::SerializeToOstream(std::ostream* output__) const {
+void PackageLoadMetrics::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   if (has_load_duration_) {
     WriteLengthDelimited(output__, 2,
@@ -214,7 +215,7 @@
   count_ = static_cast< int32_t >(0);
 }
 
-void ActionCacheStatistics::MissDetail::SerializeToOstream(std::ostream* output__) const {
+void ActionCacheStatistics::MissDetail::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(reason_));
   WriteVarint32SignExtended(output__, 2, count_);
 }
@@ -255,7 +256,7 @@
   load_time_in_ms_ = static_cast< uint64_t >(0);
 }
 
-void ActionCacheStatistics::SerializeToOstream(std::ostream* output__) const {
+void ActionCacheStatistics::SerializeToOstream(OutputStream* output__) const {
   WriteVarint64(output__, 1, size_in_bytes_);
   WriteVarint64(output__, 2, save_time_in_ms_);
   WriteVarint32SignExtended(output__, 3, hits_);
@@ -336,7 +337,7 @@
   has_sections_ = false;
 }
 
-void CommandLine::SerializeToOstream(std::ostream* output__) const {
+void CommandLine::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, command_line_label_);
   for (const auto& elem : sections_) {
     if (has_sections_) {
@@ -380,7 +381,7 @@
   has_chunk_ = false;
 }
 
-void ChunkList::SerializeToOstream(std::ostream* output__) const {
+void ChunkList::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : chunk_) {
     WriteString(output__, 1, elem);
   }
@@ -411,7 +412,7 @@
   has_option_ = false;
 }
 
-void OptionList::SerializeToOstream(std::ostream* output__) const {
+void OptionList::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : option_) {
     if (has_option_) {
       WriteLengthDelimited(output__, 1,
@@ -449,7 +450,7 @@
   has_option_list_ = false;
 }
 
-void CommandLineSection::SerializeToOstream(std::ostream* output__) const {
+void CommandLineSection::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, section_label_);
   if (has_chunk_list_) {
     WriteLengthDelimited(output__, 2,
@@ -502,7 +503,7 @@
   has_metadata_tags_ = false;
 }
 
-void Option::SerializeToOstream(std::ostream* output__) const {
+void Option::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, combined_form_);
   WriteString(output__, 2, option_name_);
   WriteString(output__, 3, option_value_);
@@ -576,7 +577,7 @@
   has_file_ = false;
 }
 
-void FileDescriptorSet::SerializeToOstream(std::ostream* output__) const {
+void FileDescriptorSet::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : file_) {
     if (has_file_) {
       WriteLengthDelimited(output__, 1,
@@ -623,7 +624,7 @@
   json_format_ = static_cast< ::bes::google::protobuf::FeatureSet::JsonFormat >(0);
 }
 
-void FeatureSet::SerializeToOstream(std::ostream* output__) const {
+void FeatureSet::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(field_presence_));
   WriteVarint32SignExtended(output__, 2, static_cast<int32_t>(enum_type_));
   WriteVarint32SignExtended(output__, 3, static_cast<int32_t>(repeated_field_encoding_));
@@ -715,7 +716,7 @@
   has_uninterpreted_option_ = false;
 }
 
-void FileOptions::SerializeToOstream(std::ostream* output__) const {
+void FileOptions::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, java_package_);
   WriteString(output__, 8, java_outer_classname_);
   WriteVarint32(output__, 10, java_multiple_files_);
@@ -920,7 +921,7 @@
   has_leading_detached_comments_ = false;
 }
 
-void SourceCodeInfo::Location::SerializeToOstream(std::ostream* output__) const {
+void SourceCodeInfo::Location::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : path_) {
     WriteVarint32SignExtended(output__, 1, elem);
   }
@@ -999,7 +1000,7 @@
   has_location_ = false;
 }
 
-void SourceCodeInfo::SerializeToOstream(std::ostream* output__) const {
+void SourceCodeInfo::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : location_) {
     if (has_location_) {
       WriteLengthDelimited(output__, 1,
@@ -1048,7 +1049,7 @@
   edition_ = static_cast< ::bes::google::protobuf::Edition >(0);
 }
 
-void FileDescriptorProto::SerializeToOstream(std::ostream* output__) const {
+void FileDescriptorProto::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   WriteString(output__, 2, package_);
   for (const auto& elem : dependency_) {
@@ -1260,7 +1261,7 @@
   repeated_ = static_cast< bool >(0);
 }
 
-void ExtensionRangeOptions::Declaration::SerializeToOstream(std::ostream* output__) const {
+void ExtensionRangeOptions::Declaration::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, number_);
   WriteString(output__, 2, full_name_);
   WriteString(output__, 3, type_);
@@ -1319,7 +1320,7 @@
   verification_ = static_cast< ::bes::google::protobuf::ExtensionRangeOptions::VerificationState >(0);
 }
 
-void ExtensionRangeOptions::SerializeToOstream(std::ostream* output__) const {
+void ExtensionRangeOptions::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : uninterpreted_option_) {
     if (has_uninterpreted_option_) {
       WriteLengthDelimited(output__, 999,
@@ -1408,7 +1409,7 @@
   has_uninterpreted_option_ = false;
 }
 
-void MessageOptions::SerializeToOstream(std::ostream* output__) const {
+void MessageOptions::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32(output__, 1, message_set_wire_format_);
   WriteVarint32(output__, 2, no_standard_descriptor_accessor_);
   WriteVarint32(output__, 3, deprecated_);
@@ -1501,7 +1502,7 @@
   has_options_ = false;
 }
 
-void DescriptorProto::ExtensionRange::SerializeToOstream(std::ostream* output__) const {
+void DescriptorProto::ExtensionRange::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, start_);
   WriteVarint32SignExtended(output__, 2, end_);
   if (has_options_) {
@@ -1548,7 +1549,7 @@
   end_ = static_cast< int32_t >(0);
 }
 
-void DescriptorProto::ReservedRange::SerializeToOstream(std::ostream* output__) const {
+void DescriptorProto::ReservedRange::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, start_);
   WriteVarint32SignExtended(output__, 2, end_);
 }
@@ -1588,7 +1589,7 @@
   has_reserved_name_ = false;
 }
 
-void DescriptorProto::SerializeToOstream(std::ostream* output__) const {
+void DescriptorProto::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   for (const auto& elem : field_) {
     if (has_field_) {
@@ -1789,7 +1790,7 @@
   has_value_ = false;
 }
 
-void FieldOptions::EditionDefault::SerializeToOstream(std::ostream* output__) const {
+void FieldOptions::EditionDefault::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 3, static_cast<int32_t>(edition_));
   WriteString(output__, 2, value_);
 }
@@ -1826,7 +1827,7 @@
   edition_removed_ = static_cast< ::bes::google::protobuf::Edition >(0);
 }
 
-void FieldOptions::FeatureSupport::SerializeToOstream(std::ostream* output__) const {
+void FieldOptions::FeatureSupport::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(edition_introduced_));
   WriteVarint32SignExtended(output__, 2, static_cast<int32_t>(edition_deprecated_));
   WriteString(output__, 3, deprecation_warning_);
@@ -1895,7 +1896,7 @@
   has_uninterpreted_option_ = false;
 }
 
-void FieldOptions::SerializeToOstream(std::ostream* output__) const {
+void FieldOptions::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(ctype_));
   WriteVarint32(output__, 2, packed_);
   WriteVarint32SignExtended(output__, 6, static_cast<int32_t>(jstype_));
@@ -2081,7 +2082,7 @@
   proto3_optional_ = static_cast< bool >(0);
 }
 
-void FieldDescriptorProto::SerializeToOstream(std::ostream* output__) const {
+void FieldDescriptorProto::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   WriteVarint32SignExtended(output__, 3, number_);
   WriteVarint32SignExtended(output__, 4, static_cast<int32_t>(label_));
@@ -2190,7 +2191,7 @@
   has_uninterpreted_option_ = false;
 }
 
-void OneofOptions::SerializeToOstream(std::ostream* output__) const {
+void OneofOptions::SerializeToOstream(OutputStream* output__) const {
   if (has_features_) {
     WriteLengthDelimited(output__, 1,
                          features_.ByteSizeLong());
@@ -2240,7 +2241,7 @@
   has_options_ = false;
 }
 
-void OneofDescriptorProto::SerializeToOstream(std::ostream* output__) const {
+void OneofDescriptorProto::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   if (has_options_) {
     WriteLengthDelimited(output__, 2,
@@ -2283,7 +2284,7 @@
   has_uninterpreted_option_ = false;
 }
 
-void EnumOptions::SerializeToOstream(std::ostream* output__) const {
+void EnumOptions::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32(output__, 2, allow_alias_);
   WriteVarint32(output__, 3, deprecated_);
   WriteVarint32(output__, 6, deprecated_legacy_json_field_conflicts_);
@@ -2359,7 +2360,7 @@
   end_ = static_cast< int32_t >(0);
 }
 
-void EnumDescriptorProto::EnumReservedRange::SerializeToOstream(std::ostream* output__) const {
+void EnumDescriptorProto::EnumReservedRange::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, start_);
   WriteVarint32SignExtended(output__, 2, end_);
 }
@@ -2394,7 +2395,7 @@
   has_reserved_name_ = false;
 }
 
-void EnumDescriptorProto::SerializeToOstream(std::ostream* output__) const {
+void EnumDescriptorProto::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   for (const auto& elem : value_) {
     if (has_value_) {
@@ -2494,7 +2495,7 @@
   has_uninterpreted_option_ = false;
 }
 
-void EnumValueOptions::SerializeToOstream(std::ostream* output__) const {
+void EnumValueOptions::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32(output__, 1, deprecated_);
   if (has_features_) {
     WriteLengthDelimited(output__, 2,
@@ -2575,7 +2576,7 @@
   has_options_ = false;
 }
 
-void EnumValueDescriptorProto::SerializeToOstream(std::ostream* output__) const {
+void EnumValueDescriptorProto::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   WriteVarint32SignExtended(output__, 2, number_);
   if (has_options_) {
@@ -2622,7 +2623,7 @@
   has_uninterpreted_option_ = false;
 }
 
-void ServiceOptions::SerializeToOstream(std::ostream* output__) const {
+void ServiceOptions::SerializeToOstream(OutputStream* output__) const {
   if (has_features_) {
     WriteLengthDelimited(output__, 34,
                          features_.ByteSizeLong());
@@ -2681,7 +2682,7 @@
   has_options_ = false;
 }
 
-void ServiceDescriptorProto::SerializeToOstream(std::ostream* output__) const {
+void ServiceDescriptorProto::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   for (const auto& elem : method_) {
     if (has_method_) {
@@ -2743,7 +2744,7 @@
   has_uninterpreted_option_ = false;
 }
 
-void MethodOptions::SerializeToOstream(std::ostream* output__) const {
+void MethodOptions::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32(output__, 33, deprecated_);
   WriteVarint32SignExtended(output__, 34, static_cast<int32_t>(idempotency_level_));
   if (has_features_) {
@@ -2815,7 +2816,7 @@
   server_streaming_ = static_cast< bool >(0);
 }
 
-void MethodDescriptorProto::SerializeToOstream(std::ostream* output__) const {
+void MethodDescriptorProto::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   WriteString(output__, 2, input_type_);
   WriteString(output__, 3, output_type_);
@@ -2885,7 +2886,7 @@
   is_extension_ = static_cast< bool >(0);
 }
 
-void UninterpretedOption::NamePart::SerializeToOstream(std::ostream* output__) const {
+void UninterpretedOption::NamePart::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_part_);
   WriteVarint32(output__, 2, is_extension_);
 }
@@ -2925,7 +2926,7 @@
   has_aggregate_value_ = false;
 }
 
-void UninterpretedOption::SerializeToOstream(std::ostream* output__) const {
+void UninterpretedOption::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : name_) {
     if (has_name_) {
       WriteLengthDelimited(output__, 2,
@@ -3012,7 +3013,7 @@
   has_fixed_features_ = false;
 }
 
-void FeatureSetDefaults::FeatureSetEditionDefault::SerializeToOstream(std::ostream* output__) const {
+void FeatureSetDefaults::FeatureSetEditionDefault::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 3, static_cast<int32_t>(edition_));
   if (has_overridable_features_) {
     WriteLengthDelimited(output__, 4,
@@ -3065,7 +3066,7 @@
   maximum_edition_ = static_cast< ::bes::google::protobuf::Edition >(0);
 }
 
-void FeatureSetDefaults::SerializeToOstream(std::ostream* output__) const {
+void FeatureSetDefaults::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : defaults_) {
     if (has_defaults_) {
       WriteLengthDelimited(output__, 1,
@@ -3124,7 +3125,7 @@
   semantic_ = static_cast< ::bes::google::protobuf::GeneratedCodeInfo::Annotation::Semantic >(0);
 }
 
-void GeneratedCodeInfo::Annotation::SerializeToOstream(std::ostream* output__) const {
+void GeneratedCodeInfo::Annotation::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : path_) {
     WriteVarint32SignExtended(output__, 1, elem);
   }
@@ -3187,7 +3188,7 @@
   has_annotation_ = false;
 }
 
-void GeneratedCodeInfo::SerializeToOstream(std::ostream* output__) const {
+void GeneratedCodeInfo::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : annotation_) {
     if (has_annotation_) {
       WriteLengthDelimited(output__, 1,
@@ -3227,7 +3228,7 @@
   exit_code_ = static_cast< uint32_t >(0);
 }
 
-void FailureDetailMetadata::SerializeToOstream(std::ostream* output__) const {
+void FailureDetailMetadata::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32(output__, 1, exit_code_);
 }
 
@@ -3251,7 +3252,7 @@
   code_ = static_cast< ::bes::failure_details::ActionCache::Code >(0);
 }
 
-void ActionCache::SerializeToOstream(std::ostream* output__) const {
+void ActionCache::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3275,7 +3276,7 @@
   code_ = static_cast< ::bes::failure_details::ActionQuery::Code >(0);
 }
 
-void ActionQuery::SerializeToOstream(std::ostream* output__) const {
+void ActionQuery::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3299,7 +3300,7 @@
   code_ = static_cast< ::bes::failure_details::ActionRewinding::Code >(0);
 }
 
-void ActionRewinding::SerializeToOstream(std::ostream* output__) const {
+void ActionRewinding::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3323,7 +3324,7 @@
   code_ = static_cast< ::bes::failure_details::Analysis::Code >(0);
 }
 
-void Analysis::SerializeToOstream(std::ostream* output__) const {
+void Analysis::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3347,7 +3348,7 @@
   code_ = static_cast< ::bes::failure_details::BuildConfiguration::Code >(0);
 }
 
-void BuildConfiguration::SerializeToOstream(std::ostream* output__) const {
+void BuildConfiguration::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3371,7 +3372,7 @@
   code_ = static_cast< ::bes::failure_details::BuildProgress::Code >(0);
 }
 
-void BuildProgress::SerializeToOstream(std::ostream* output__) const {
+void BuildProgress::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3395,7 +3396,7 @@
   code_ = static_cast< ::bes::failure_details::BuildReport::Code >(0);
 }
 
-void BuildReport::SerializeToOstream(std::ostream* output__) const {
+void BuildReport::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3419,7 +3420,7 @@
   code_ = static_cast< ::bes::failure_details::CanonicalizeFlags::Code >(0);
 }
 
-void CanonicalizeFlags::SerializeToOstream(std::ostream* output__) const {
+void CanonicalizeFlags::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3443,7 +3444,7 @@
   code_ = static_cast< ::bes::failure_details::CleanCommand::Code >(0);
 }
 
-void CleanCommand::SerializeToOstream(std::ostream* output__) const {
+void CleanCommand::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3467,7 +3468,7 @@
   code_ = static_cast< ::bes::failure_details::ClientEnvironment::Code >(0);
 }
 
-void ClientEnvironment::SerializeToOstream(std::ostream* output__) const {
+void ClientEnvironment::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3491,7 +3492,7 @@
   code_ = static_cast< ::bes::failure_details::Command::Code >(0);
 }
 
-void Command::SerializeToOstream(std::ostream* output__) const {
+void Command::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3515,7 +3516,7 @@
   code_ = static_cast< ::bes::failure_details::ConfigCommand::Code >(0);
 }
 
-void ConfigCommand::SerializeToOstream(std::ostream* output__) const {
+void ConfigCommand::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3539,7 +3540,7 @@
   code_ = static_cast< ::bes::failure_details::ConfigurableQuery::Code >(0);
 }
 
-void ConfigurableQuery::SerializeToOstream(std::ostream* output__) const {
+void ConfigurableQuery::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3563,7 +3564,7 @@
   code_ = static_cast< ::bes::failure_details::CppCompile::Code >(0);
 }
 
-void CppCompile::SerializeToOstream(std::ostream* output__) const {
+void CppCompile::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3587,7 +3588,7 @@
   code_ = static_cast< ::bes::failure_details::CppLink::Code >(0);
 }
 
-void CppLink::SerializeToOstream(std::ostream* output__) const {
+void CppLink::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3614,7 +3615,7 @@
   oom_detector_override_ = static_cast< bool >(0);
 }
 
-void Crash::SerializeToOstream(std::ostream* output__) const {
+void Crash::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
   for (const auto& elem : causes_) {
     if (has_causes_) {
@@ -3667,7 +3668,7 @@
   code_ = static_cast< ::bes::failure_details::CrashOptions::Code >(0);
 }
 
-void CrashOptions::SerializeToOstream(std::ostream* output__) const {
+void CrashOptions::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3691,7 +3692,7 @@
   code_ = static_cast< ::bes::failure_details::DiffAwareness::Code >(0);
 }
 
-void DiffAwareness::SerializeToOstream(std::ostream* output__) const {
+void DiffAwareness::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3715,7 +3716,7 @@
   code_ = static_cast< ::bes::failure_details::DumpCommand::Code >(0);
 }
 
-void DumpCommand::SerializeToOstream(std::ostream* output__) const {
+void DumpCommand::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3739,7 +3740,7 @@
   code_ = static_cast< ::bes::failure_details::DynamicExecution::Code >(0);
 }
 
-void DynamicExecution::SerializeToOstream(std::ostream* output__) const {
+void DynamicExecution::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3763,7 +3764,7 @@
   code_ = static_cast< ::bes::failure_details::Execution::Code >(0);
 }
 
-void Execution::SerializeToOstream(std::ostream* output__) const {
+void Execution::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3787,7 +3788,7 @@
   code_ = static_cast< ::bes::failure_details::ExecutionOptions::Code >(0);
 }
 
-void ExecutionOptions::SerializeToOstream(std::ostream* output__) const {
+void ExecutionOptions::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3811,7 +3812,7 @@
   code_ = static_cast< ::bes::failure_details::ExternalDeps::Code >(0);
 }
 
-void ExternalDeps::SerializeToOstream(std::ostream* output__) const {
+void ExternalDeps::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3835,7 +3836,7 @@
   code_ = static_cast< ::bes::failure_details::ExternalRepository::Code >(0);
 }
 
-void ExternalRepository::SerializeToOstream(std::ostream* output__) const {
+void ExternalRepository::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3859,7 +3860,7 @@
   code_ = static_cast< ::bes::failure_details::FailAction::Code >(0);
 }
 
-void FailAction::SerializeToOstream(std::ostream* output__) const {
+void FailAction::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3883,7 +3884,7 @@
   code_ = static_cast< ::bes::failure_details::FetchCommand::Code >(0);
 }
 
-void FetchCommand::SerializeToOstream(std::ostream* output__) const {
+void FetchCommand::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3907,7 +3908,7 @@
   code_ = static_cast< ::bes::failure_details::Filesystem::Code >(0);
 }
 
-void Filesystem::SerializeToOstream(std::ostream* output__) const {
+void Filesystem::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3931,7 +3932,7 @@
   code_ = static_cast< ::bes::failure_details::GrpcServer::Code >(0);
 }
 
-void GrpcServer::SerializeToOstream(std::ostream* output__) const {
+void GrpcServer::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3955,7 +3956,7 @@
   code_ = static_cast< ::bes::failure_details::HelpCommand::Code >(0);
 }
 
-void HelpCommand::SerializeToOstream(std::ostream* output__) const {
+void HelpCommand::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -3979,7 +3980,7 @@
   code_ = static_cast< ::bes::failure_details::PackageLoading::Code >(0);
 }
 
-void PackageLoading::SerializeToOstream(std::ostream* output__) const {
+void PackageLoading::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4005,7 +4006,7 @@
   package_loading_code_ = static_cast< ::bes::failure_details::PackageLoading::Code >(0);
 }
 
-void IncludeScanning::SerializeToOstream(std::ostream* output__) const {
+void IncludeScanning::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
   WriteVarint32SignExtended(output__, 2, static_cast<int32_t>(package_loading_code_));
 }
@@ -4037,7 +4038,7 @@
   code_ = static_cast< ::bes::failure_details::InfoCommand::Code >(0);
 }
 
-void InfoCommand::SerializeToOstream(std::ostream* output__) const {
+void InfoCommand::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4061,7 +4062,7 @@
   code_ = static_cast< ::bes::failure_details::Interrupted::Code >(0);
 }
 
-void Interrupted::SerializeToOstream(std::ostream* output__) const {
+void Interrupted::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4085,7 +4086,7 @@
   code_ = static_cast< ::bes::failure_details::JavaCompile::Code >(0);
 }
 
-void JavaCompile::SerializeToOstream(std::ostream* output__) const {
+void JavaCompile::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4109,7 +4110,7 @@
   code_ = static_cast< ::bes::failure_details::LocalExecution::Code >(0);
 }
 
-void LocalExecution::SerializeToOstream(std::ostream* output__) const {
+void LocalExecution::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4133,7 +4134,7 @@
   code_ = static_cast< ::bes::failure_details::LtoAction::Code >(0);
 }
 
-void LtoAction::SerializeToOstream(std::ostream* output__) const {
+void LtoAction::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4157,7 +4158,7 @@
   code_ = static_cast< ::bes::failure_details::MemoryOptions::Code >(0);
 }
 
-void MemoryOptions::SerializeToOstream(std::ostream* output__) const {
+void MemoryOptions::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4181,7 +4182,7 @@
   code_ = static_cast< ::bes::failure_details::MobileInstall::Code >(0);
 }
 
-void MobileInstall::SerializeToOstream(std::ostream* output__) const {
+void MobileInstall::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4205,7 +4206,7 @@
   code_ = static_cast< ::bes::failure_details::ModCommand::Code >(0);
 }
 
-void ModCommand::SerializeToOstream(std::ostream* output__) const {
+void ModCommand::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4229,7 +4230,7 @@
   code_ = static_cast< ::bes::failure_details::NinjaAction::Code >(0);
 }
 
-void NinjaAction::SerializeToOstream(std::ostream* output__) const {
+void NinjaAction::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4253,7 +4254,7 @@
   code_ = static_cast< ::bes::failure_details::PackageOptions::Code >(0);
 }
 
-void PackageOptions::SerializeToOstream(std::ostream* output__) const {
+void PackageOptions::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4277,7 +4278,7 @@
   code_ = static_cast< ::bes::failure_details::PrintActionCommand::Code >(0);
 }
 
-void PrintActionCommand::SerializeToOstream(std::ostream* output__) const {
+void PrintActionCommand::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4301,7 +4302,7 @@
   code_ = static_cast< ::bes::failure_details::ProfileCommand::Code >(0);
 }
 
-void ProfileCommand::SerializeToOstream(std::ostream* output__) const {
+void ProfileCommand::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4325,7 +4326,7 @@
   code_ = static_cast< ::bes::failure_details::Query::Code >(0);
 }
 
-void Query::SerializeToOstream(std::ostream* output__) const {
+void Query::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4349,7 +4350,7 @@
   code_ = static_cast< ::bes::failure_details::RemoteAnalysisCaching::Code >(0);
 }
 
-void RemoteAnalysisCaching::SerializeToOstream(std::ostream* output__) const {
+void RemoteAnalysisCaching::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4373,7 +4374,7 @@
   code_ = static_cast< ::bes::failure_details::RemoteExecution::Code >(0);
 }
 
-void RemoteExecution::SerializeToOstream(std::ostream* output__) const {
+void RemoteExecution::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4397,7 +4398,7 @@
   code_ = static_cast< ::bes::failure_details::RemoteOptions::Code >(0);
 }
 
-void RemoteOptions::SerializeToOstream(std::ostream* output__) const {
+void RemoteOptions::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4421,7 +4422,7 @@
   code_ = static_cast< ::bes::failure_details::RunCommand::Code >(0);
 }
 
-void RunCommand::SerializeToOstream(std::ostream* output__) const {
+void RunCommand::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4445,7 +4446,7 @@
   code_ = static_cast< ::bes::failure_details::Sandbox::Code >(0);
 }
 
-void Sandbox::SerializeToOstream(std::ostream* output__) const {
+void Sandbox::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4469,7 +4470,7 @@
   code_ = static_cast< ::bes::failure_details::Skyfocus::Code >(0);
 }
 
-void Skyfocus::SerializeToOstream(std::ostream* output__) const {
+void Skyfocus::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4497,7 +4498,7 @@
   spawn_exit_code_ = static_cast< int32_t >(0);
 }
 
-void Spawn::SerializeToOstream(std::ostream* output__) const {
+void Spawn::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
   WriteVarint32(output__, 2, catastrophic_);
   WriteVarint32SignExtended(output__, 3, spawn_exit_code_);
@@ -4537,7 +4538,7 @@
   code_ = static_cast< ::bes::failure_details::StarlarkAction::Code >(0);
 }
 
-void StarlarkAction::SerializeToOstream(std::ostream* output__) const {
+void StarlarkAction::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4561,7 +4562,7 @@
   code_ = static_cast< ::bes::failure_details::StarlarkLoading::Code >(0);
 }
 
-void StarlarkLoading::SerializeToOstream(std::ostream* output__) const {
+void StarlarkLoading::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4585,7 +4586,7 @@
   code_ = static_cast< ::bes::failure_details::SymlinkAction::Code >(0);
 }
 
-void SymlinkAction::SerializeToOstream(std::ostream* output__) const {
+void SymlinkAction::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4609,7 +4610,7 @@
   code_ = static_cast< ::bes::failure_details::SymlinkForest::Code >(0);
 }
 
-void SymlinkForest::SerializeToOstream(std::ostream* output__) const {
+void SymlinkForest::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4633,7 +4634,7 @@
   code_ = static_cast< ::bes::failure_details::SyncCommand::Code >(0);
 }
 
-void SyncCommand::SerializeToOstream(std::ostream* output__) const {
+void SyncCommand::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4657,7 +4658,7 @@
   code_ = static_cast< ::bes::failure_details::TargetPatterns::Code >(0);
 }
 
-void TargetPatterns::SerializeToOstream(std::ostream* output__) const {
+void TargetPatterns::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4681,7 +4682,7 @@
   code_ = static_cast< ::bes::failure_details::TestAction::Code >(0);
 }
 
-void TestAction::SerializeToOstream(std::ostream* output__) const {
+void TestAction::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4705,7 +4706,7 @@
   code_ = static_cast< ::bes::failure_details::TestCommand::Code >(0);
 }
 
-void TestCommand::SerializeToOstream(std::ostream* output__) const {
+void TestCommand::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4729,7 +4730,7 @@
   code_ = static_cast< ::bes::failure_details::Toolchain::Code >(0);
 }
 
-void Toolchain::SerializeToOstream(std::ostream* output__) const {
+void Toolchain::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4753,7 +4754,7 @@
   code_ = static_cast< ::bes::failure_details::VersionCommand::Code >(0);
 }
 
-void VersionCommand::SerializeToOstream(std::ostream* output__) const {
+void VersionCommand::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4777,7 +4778,7 @@
   code_ = static_cast< ::bes::failure_details::Worker::Code >(0);
 }
 
-void Worker::SerializeToOstream(std::ostream* output__) const {
+void Worker::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4801,7 +4802,7 @@
   code_ = static_cast< ::bes::failure_details::WorkspaceStatus::Code >(0);
 }
 
-void WorkspaceStatus::SerializeToOstream(std::ostream* output__) const {
+void WorkspaceStatus::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4825,7 +4826,7 @@
   code_ = static_cast< ::bes::failure_details::Workspaces::Code >(0);
 }
 
-void Workspaces::SerializeToOstream(std::ostream* output__) const {
+void Workspaces::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(code_));
 }
 
@@ -4912,7 +4913,7 @@
   has_remote_analysis_caching_ = false;
 }
 
-void FailureDetail::SerializeToOstream(std::ostream* output__) const {
+void FailureDetail::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, message_);
   if (has_interrupted_) {
     WriteLengthDelimited(output__, 101,
@@ -5769,7 +5770,7 @@
   has_stack_trace_ = false;
 }
 
-void Throwable::SerializeToOstream(std::ostream* output__) const {
+void Throwable::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, throwable_class_);
   WriteString(output__, 2, message_);
   for (const auto& elem : stack_trace_) {
@@ -5820,7 +5821,7 @@
   has_strategy_allowlist_ = false;
 }
 
-void MnemonicPolicy::SerializeToOstream(std::ostream* output__) const {
+void MnemonicPolicy::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : default_allowlist_) {
     WriteString(output__, 1, elem);
   }
@@ -5874,7 +5875,7 @@
   has_dynamic_local_policy_ = false;
 }
 
-void StrategyPolicy::SerializeToOstream(std::ostream* output__) const {
+void StrategyPolicy::SerializeToOstream(OutputStream* output__) const {
   if (has_mnemonic_policy_) {
     WriteLengthDelimited(output__, 1,
                          mnemonic_policy_.ByteSizeLong());
@@ -5929,7 +5930,7 @@
   has_strategy_ = false;
 }
 
-void StrategiesForMnemonic::SerializeToOstream(std::ostream* output__) const {
+void StrategiesForMnemonic::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, mnemonic_);
   for (const auto& elem : strategy_) {
     WriteString(output__, 2, elem);
@@ -5973,7 +5974,7 @@
   has_strategy_policy_ = false;
 }
 
-void InvocationPolicy::SerializeToOstream(std::ostream* output__) const {
+void InvocationPolicy::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : flag_policies_) {
     if (has_flag_policies_) {
       WriteLengthDelimited(output__, 1,
@@ -6021,7 +6022,7 @@
 UseDefault::UseDefault() {
 }
 
-void UseDefault::SerializeToOstream(std::ostream* output__) const {
+void UseDefault::SerializeToOstream(OutputStream* output__) const {
 }
 
 size_t UseDefault::ByteSizeLong() const {
@@ -6038,7 +6039,7 @@
   has_use_default_ = false;
 }
 
-void AllowValues::SerializeToOstream(std::ostream* output__) const {
+void AllowValues::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : allowed_values_) {
     WriteString(output__, 1, elem);
   }
@@ -6092,7 +6093,7 @@
   has_use_default_ = false;
 }
 
-void DisallowValues::SerializeToOstream(std::ostream* output__) const {
+void DisallowValues::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : disallowed_values_) {
     WriteString(output__, 1, elem);
   }
@@ -6146,7 +6147,7 @@
   behavior_ = static_cast< ::bes::blaze::invocation_policy::SetValue::Behavior >(0);
 }
 
-void SetValue::SerializeToOstream(std::ostream* output__) const {
+void SetValue::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : flag_value_) {
     WriteString(output__, 1, elem);
   }
@@ -6190,7 +6191,7 @@
   has_allow_values_ = false;
 }
 
-void FlagPolicy::SerializeToOstream(std::ostream* output__) const {
+void FlagPolicy::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, flag_name_);
   for (const auto& elem : commands_) {
     WriteString(output__, 2, elem);
@@ -6284,7 +6285,7 @@
   has_details_ = false;
 }
 
-void BuildEventId::UnknownBuildEventId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::UnknownBuildEventId::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, details_);
 }
 
@@ -6308,7 +6309,7 @@
   opaque_count_ = static_cast< int32_t >(0);
 }
 
-void BuildEventId::ProgressId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::ProgressId::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, opaque_count_);
 }
 
@@ -6330,7 +6331,7 @@
 BuildEventId::BuildStartedId::BuildStartedId() {
 }
 
-void BuildEventId::BuildStartedId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::BuildStartedId::SerializeToOstream(OutputStream* output__) const {
 }
 
 size_t BuildEventId::BuildStartedId::ByteSizeLong() const {
@@ -6344,7 +6345,7 @@
 BuildEventId::UnstructuredCommandLineId::UnstructuredCommandLineId() {
 }
 
-void BuildEventId::UnstructuredCommandLineId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::UnstructuredCommandLineId::SerializeToOstream(OutputStream* output__) const {
 }
 
 size_t BuildEventId::UnstructuredCommandLineId::ByteSizeLong() const {
@@ -6359,7 +6360,7 @@
   has_command_line_label_ = false;
 }
 
-void BuildEventId::StructuredCommandLineId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::StructuredCommandLineId::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, command_line_label_);
 }
 
@@ -6381,7 +6382,7 @@
 BuildEventId::WorkspaceStatusId::WorkspaceStatusId() {
 }
 
-void BuildEventId::WorkspaceStatusId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::WorkspaceStatusId::SerializeToOstream(OutputStream* output__) const {
 }
 
 size_t BuildEventId::WorkspaceStatusId::ByteSizeLong() const {
@@ -6395,7 +6396,7 @@
 BuildEventId::OptionsParsedId::OptionsParsedId() {
 }
 
-void BuildEventId::OptionsParsedId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::OptionsParsedId::SerializeToOstream(OutputStream* output__) const {
 }
 
 size_t BuildEventId::OptionsParsedId::ByteSizeLong() const {
@@ -6410,7 +6411,7 @@
   has_url_ = false;
 }
 
-void BuildEventId::FetchId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::FetchId::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, url_);
 }
 
@@ -6433,7 +6434,7 @@
   has_pattern_ = false;
 }
 
-void BuildEventId::PatternExpandedId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::PatternExpandedId::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : pattern_) {
     WriteString(output__, 1, elem);
   }
@@ -6463,7 +6464,7 @@
 BuildEventId::WorkspaceConfigId::WorkspaceConfigId() {
 }
 
-void BuildEventId::WorkspaceConfigId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::WorkspaceConfigId::SerializeToOstream(OutputStream* output__) const {
 }
 
 size_t BuildEventId::WorkspaceConfigId::ByteSizeLong() const {
@@ -6477,7 +6478,7 @@
 BuildEventId::BuildMetadataId::BuildMetadataId() {
 }
 
-void BuildEventId::BuildMetadataId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::BuildMetadataId::SerializeToOstream(OutputStream* output__) const {
 }
 
 size_t BuildEventId::BuildMetadataId::ByteSizeLong() const {
@@ -6493,7 +6494,7 @@
   has_aspect_ = false;
 }
 
-void BuildEventId::TargetConfiguredId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::TargetConfiguredId::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, label_);
   WriteString(output__, 2, aspect_);
 }
@@ -6524,7 +6525,7 @@
   has_id_ = false;
 }
 
-void BuildEventId::NamedSetOfFilesId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::NamedSetOfFilesId::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, id_);
 }
 
@@ -6547,7 +6548,7 @@
   has_id_ = false;
 }
 
-void BuildEventId::ConfigurationId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::ConfigurationId::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, id_);
 }
 
@@ -6572,7 +6573,7 @@
   has_aspect_ = false;
 }
 
-void BuildEventId::TargetCompletedId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::TargetCompletedId::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, label_);
   if (has_configuration_) {
     WriteLengthDelimited(output__, 3,
@@ -6618,7 +6619,7 @@
   has_configuration_ = false;
 }
 
-void BuildEventId::ActionCompletedId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::ActionCompletedId::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, primary_output_);
   WriteString(output__, 2, label_);
   if (has_configuration_) {
@@ -6662,7 +6663,7 @@
   has_label_ = false;
 }
 
-void BuildEventId::UnconfiguredLabelId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::UnconfiguredLabelId::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, label_);
 }
 
@@ -6686,7 +6687,7 @@
   has_configuration_ = false;
 }
 
-void BuildEventId::ConfiguredLabelId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::ConfiguredLabelId::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, label_);
   if (has_configuration_) {
     WriteLengthDelimited(output__, 2,
@@ -6729,7 +6730,7 @@
   attempt_ = static_cast< int32_t >(0);
 }
 
-void BuildEventId::TestResultId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::TestResultId::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, label_);
   if (has_configuration_) {
     WriteLengthDelimited(output__, 5,
@@ -6798,7 +6799,7 @@
   opaque_count_ = static_cast< int32_t >(0);
 }
 
-void BuildEventId::TestProgressId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::TestProgressId::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, label_);
   if (has_configuration_) {
     WriteLengthDelimited(output__, 2,
@@ -6867,7 +6868,7 @@
   has_configuration_ = false;
 }
 
-void BuildEventId::TestSummaryId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::TestSummaryId::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, label_);
   if (has_configuration_) {
     WriteLengthDelimited(output__, 2,
@@ -6904,7 +6905,7 @@
   has_configuration_ = false;
 }
 
-void BuildEventId::TargetSummaryId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::TargetSummaryId::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, label_);
   if (has_configuration_) {
     WriteLengthDelimited(output__, 2,
@@ -6939,7 +6940,7 @@
 BuildEventId::BuildFinishedId::BuildFinishedId() {
 }
 
-void BuildEventId::BuildFinishedId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::BuildFinishedId::SerializeToOstream(OutputStream* output__) const {
 }
 
 size_t BuildEventId::BuildFinishedId::ByteSizeLong() const {
@@ -6953,7 +6954,7 @@
 BuildEventId::BuildToolLogsId::BuildToolLogsId() {
 }
 
-void BuildEventId::BuildToolLogsId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::BuildToolLogsId::SerializeToOstream(OutputStream* output__) const {
 }
 
 size_t BuildEventId::BuildToolLogsId::ByteSizeLong() const {
@@ -6967,7 +6968,7 @@
 BuildEventId::BuildMetricsId::BuildMetricsId() {
 }
 
-void BuildEventId::BuildMetricsId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::BuildMetricsId::SerializeToOstream(OutputStream* output__) const {
 }
 
 size_t BuildEventId::BuildMetricsId::ByteSizeLong() const {
@@ -6981,7 +6982,7 @@
 BuildEventId::ConvenienceSymlinksIdentifiedId::ConvenienceSymlinksIdentifiedId() {
 }
 
-void BuildEventId::ConvenienceSymlinksIdentifiedId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::ConvenienceSymlinksIdentifiedId::SerializeToOstream(OutputStream* output__) const {
 }
 
 size_t BuildEventId::ConvenienceSymlinksIdentifiedId::ByteSizeLong() const {
@@ -6995,7 +6996,7 @@
 BuildEventId::ExecRequestId::ExecRequestId() {
 }
 
-void BuildEventId::ExecRequestId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::ExecRequestId::SerializeToOstream(OutputStream* output__) const {
 }
 
 size_t BuildEventId::ExecRequestId::ByteSizeLong() const {
@@ -7037,7 +7038,7 @@
   has_exec_request_ = false;
 }
 
-void BuildEventId::SerializeToOstream(std::ostream* output__) const {
+void BuildEventId::SerializeToOstream(OutputStream* output__) const {
   if (has_unknown_) {
     WriteLengthDelimited(output__, 1,
                          unknown_.ByteSizeLong());
@@ -7417,7 +7418,7 @@
   has_stderr_ = false;
 }
 
-void Progress::SerializeToOstream(std::ostream* output__) const {
+void Progress::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, stdout_);
   WriteString(output__, 2, stderr_);
 }
@@ -7450,7 +7451,7 @@
   has_description_ = false;
 }
 
-void Aborted::SerializeToOstream(std::ostream* output__) const {
+void Aborted::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(reason_));
   WriteString(output__, 2, description_);
 }
@@ -7491,7 +7492,7 @@
   server_pid_ = static_cast< int64_t >(0);
 }
 
-void BuildStarted::SerializeToOstream(std::ostream* output__) const {
+void BuildStarted::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, uuid_);
   WriteVarint64(output__, 2, start_time_millis_);
   if (has_start_time_) {
@@ -7583,7 +7584,7 @@
   has_local_exec_root_ = false;
 }
 
-void WorkspaceConfig::SerializeToOstream(std::ostream* output__) const {
+void WorkspaceConfig::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, local_exec_root_);
 }
 
@@ -7606,7 +7607,7 @@
   has_args_ = false;
 }
 
-void UnstructuredCommandLine::SerializeToOstream(std::ostream* output__) const {
+void UnstructuredCommandLine::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : args_) {
     WriteString(output__, 1, elem);
   }
@@ -7642,7 +7643,7 @@
   has_tool_tag_ = false;
 }
 
-void OptionsParsed::SerializeToOstream(std::ostream* output__) const {
+void OptionsParsed::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : startup_options_) {
     WriteString(output__, 1, elem);
   }
@@ -7743,7 +7744,7 @@
   success_ = static_cast< bool >(0);
 }
 
-void Fetch::SerializeToOstream(std::ostream* output__) const {
+void Fetch::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32(output__, 1, success_);
 }
 
@@ -7767,7 +7768,7 @@
   has_value_ = false;
 }
 
-void WorkspaceStatus::Item::SerializeToOstream(std::ostream* output__) const {
+void WorkspaceStatus::Item::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, key_);
   WriteString(output__, 2, value_);
 }
@@ -7798,7 +7799,7 @@
   has_item_ = false;
 }
 
-void WorkspaceStatus::SerializeToOstream(std::ostream* output__) const {
+void WorkspaceStatus::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : item_) {
     if (has_item_) {
       WriteLengthDelimited(output__, 1,
@@ -7835,7 +7836,7 @@
   has_value_ = false;
 }
 
-void BuildMetadata::MetadataEntry::SerializeToOstream(std::ostream* output__) const {
+void BuildMetadata::MetadataEntry::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, key_);
   WriteString(output__, 2, value_);
 }
@@ -7866,7 +7867,7 @@
   has_metadata_ = false;
 }
 
-void BuildMetadata::SerializeToOstream(std::ostream* output__) const {
+void BuildMetadata::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : metadata_) {
     if (has_metadata_) {
       WriteLengthDelimited(output__, 1,
@@ -7903,7 +7904,7 @@
   has_value_ = false;
 }
 
-void Configuration::MakeVariableEntry::SerializeToOstream(std::ostream* output__) const {
+void Configuration::MakeVariableEntry::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, key_);
   WriteString(output__, 2, value_);
 }
@@ -7939,7 +7940,7 @@
   is_tool_ = static_cast< bool >(0);
 }
 
-void Configuration::SerializeToOstream(std::ostream* output__) const {
+void Configuration::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, mnemonic_);
   WriteString(output__, 2, platform_name_);
   WriteString(output__, 3, cpu_);
@@ -8008,7 +8009,7 @@
   has_test_labels_ = false;
 }
 
-void PatternExpanded::TestSuiteExpansion::SerializeToOstream(std::ostream* output__) const {
+void PatternExpanded::TestSuiteExpansion::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, suite_label_);
   for (const auto& elem : test_labels_) {
     WriteString(output__, 2, elem);
@@ -8047,7 +8048,7 @@
   has_test_suite_expansions_ = false;
 }
 
-void PatternExpanded::SerializeToOstream(std::ostream* output__) const {
+void PatternExpanded::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : test_suite_expansions_) {
     if (has_test_suite_expansions_) {
       WriteLengthDelimited(output__, 1,
@@ -8086,7 +8087,7 @@
   has_tag_ = false;
 }
 
-void TargetConfigured::SerializeToOstream(std::ostream* output__) const {
+void TargetConfigured::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, target_kind_);
   WriteVarint32SignExtended(output__, 2, static_cast<int32_t>(test_size_));
   for (const auto& elem : tag_) {
@@ -8140,7 +8141,7 @@
   length_ = static_cast< int64_t >(0);
 }
 
-void File::SerializeToOstream(std::ostream* output__) const {
+void File::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : path_prefix_) {
     WriteString(output__, 4, elem);
   }
@@ -8220,7 +8221,7 @@
   has_file_sets_ = false;
 }
 
-void NamedSetOfFiles::SerializeToOstream(std::ostream* output__) const {
+void NamedSetOfFiles::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : files_) {
     if (has_files_) {
       WriteLengthDelimited(output__, 1,
@@ -8292,7 +8293,7 @@
   has_strategy_details_ = false;
 }
 
-void ActionExecuted::SerializeToOstream(std::ostream* output__) const {
+void ActionExecuted::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32(output__, 1, success_);
   WriteString(output__, 8, type_);
   WriteVarint32SignExtended(output__, 2, exit_code_);
@@ -8492,7 +8493,7 @@
   has_inline_files_ = false;
 }
 
-void OutputGroup::SerializeToOstream(std::ostream* output__) const {
+void OutputGroup::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   for (const auto& elem : file_sets_) {
     if (has_file_sets_) {
@@ -8577,7 +8578,7 @@
   has_failure_detail_ = false;
 }
 
-void TargetComplete::SerializeToOstream(std::ostream* output__) const {
+void TargetComplete::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32(output__, 1, success_);
   WriteString(output__, 5, target_kind_);
   WriteVarint32SignExtended(output__, 6, static_cast<int32_t>(test_size_));
@@ -8733,7 +8734,7 @@
   has_time_ = false;
 }
 
-void TestResult::ExecutionInfo::TimingBreakdown::SerializeToOstream(std::ostream* output__) const {
+void TestResult::ExecutionInfo::TimingBreakdown::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : child_) {
     if (has_child_) {
       WriteLengthDelimited(output__, 1,
@@ -8800,7 +8801,7 @@
   value_ = static_cast< int64_t >(0);
 }
 
-void TestResult::ExecutionInfo::ResourceUsage::SerializeToOstream(std::ostream* output__) const {
+void TestResult::ExecutionInfo::ResourceUsage::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   WriteVarint64(output__, 2, value_);
 }
@@ -8840,7 +8841,7 @@
   has_resource_usage_ = false;
 }
 
-void TestResult::ExecutionInfo::SerializeToOstream(std::ostream* output__) const {
+void TestResult::ExecutionInfo::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, timeout_seconds_);
   WriteString(output__, 2, strategy_);
   WriteVarint32(output__, 6, cached_remotely_);
@@ -8942,7 +8943,7 @@
   has_execution_info_ = false;
 }
 
-void TestResult::SerializeToOstream(std::ostream* output__) const {
+void TestResult::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 5, static_cast<int32_t>(status_));
   WriteString(output__, 9, status_details_);
   WriteVarint32(output__, 4, cached_locally_);
@@ -9073,7 +9074,7 @@
   has_uri_ = false;
 }
 
-void TestProgress::SerializeToOstream(std::ostream* output__) const {
+void TestProgress::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, uri_);
 }
 
@@ -9118,7 +9119,7 @@
   has_total_run_duration_ = false;
 }
 
-void TestSummary::SerializeToOstream(std::ostream* output__) const {
+void TestSummary::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 5, static_cast<int32_t>(overall_status_));
   WriteVarint32SignExtended(output__, 1, total_run_count_);
   WriteVarint32SignExtended(output__, 10, run_count_);
@@ -9289,7 +9290,7 @@
   overall_test_status_ = static_cast< ::bes::build_event_stream::TestStatus >(0);
 }
 
-void TargetSummary::SerializeToOstream(std::ostream* output__) const {
+void TargetSummary::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32(output__, 1, overall_build_success_);
   WriteVarint32SignExtended(output__, 2, static_cast<int32_t>(overall_test_status_));
 }
@@ -9322,7 +9323,7 @@
   code_ = static_cast< int32_t >(0);
 }
 
-void BuildFinished::ExitCode::SerializeToOstream(std::ostream* output__) const {
+void BuildFinished::ExitCode::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   WriteVarint32SignExtended(output__, 2, code_);
 }
@@ -9354,7 +9355,7 @@
   was_suspended_ = static_cast< bool >(0);
 }
 
-void BuildFinished::AnomalyReport::SerializeToOstream(std::ostream* output__) const {
+void BuildFinished::AnomalyReport::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32(output__, 1, was_suspended_);
 }
 
@@ -9384,7 +9385,7 @@
   has_failure_detail_ = false;
 }
 
-void BuildFinished::SerializeToOstream(std::ostream* output__) const {
+void BuildFinished::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32(output__, 1, overall_success_);
   if (has_exit_code_) {
     WriteLengthDelimited(output__, 3,
@@ -9477,7 +9478,7 @@
   actions_created_ = static_cast< int64_t >(0);
 }
 
-void BuildMetrics::ActionSummary::ActionData::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::ActionSummary::ActionData::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, mnemonic_);
   WriteVarint64(output__, 2, actions_executed_);
   WriteVarint64(output__, 3, first_started_ms_);
@@ -9561,7 +9562,7 @@
   has_exec_kind_ = false;
 }
 
-void BuildMetrics::ActionSummary::RunnerCount::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::ActionSummary::RunnerCount::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   WriteVarint32SignExtended(output__, 2, count_);
   WriteString(output__, 3, exec_kind_);
@@ -9610,7 +9611,7 @@
   has_action_cache_statistics_ = false;
 }
 
-void BuildMetrics::ActionSummary::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::ActionSummary::SerializeToOstream(OutputStream* output__) const {
   WriteVarint64(output__, 1, actions_created_);
   WriteVarint64(output__, 3, actions_created_not_including_aspects_);
   WriteVarint64(output__, 2, actions_executed_);
@@ -9714,7 +9715,7 @@
   garbage_collected_ = static_cast< int64_t >(0);
 }
 
-void BuildMetrics::MemoryMetrics::GarbageMetrics::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::MemoryMetrics::GarbageMetrics::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, type_);
   WriteVarint64(output__, 2, garbage_collected_);
 }
@@ -9751,7 +9752,7 @@
   has_garbage_metrics_ = false;
 }
 
-void BuildMetrics::MemoryMetrics::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::MemoryMetrics::SerializeToOstream(OutputStream* output__) const {
   WriteVarint64(output__, 1, used_heap_size_post_build_);
   WriteVarint64(output__, 2, peak_post_gc_heap_size_);
   WriteVarint64(output__, 4, peak_post_gc_tenured_space_heap_size_);
@@ -9816,7 +9817,7 @@
   targets_configured_not_including_aspects_ = static_cast< int64_t >(0);
 }
 
-void BuildMetrics::TargetMetrics::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::TargetMetrics::SerializeToOstream(OutputStream* output__) const {
   WriteVarint64(output__, 1, targets_loaded_);
   WriteVarint64(output__, 2, targets_configured_);
   WriteVarint64(output__, 3, targets_configured_not_including_aspects_);
@@ -9857,7 +9858,7 @@
   has_package_load_metrics_ = false;
 }
 
-void BuildMetrics::PackageMetrics::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::PackageMetrics::SerializeToOstream(OutputStream* output__) const {
   WriteVarint64(output__, 1, packages_loaded_);
   for (const auto& elem : package_load_metrics_) {
     if (has_package_load_metrics_) {
@@ -9910,7 +9911,7 @@
   actions_execution_start_in_ms_ = static_cast< int64_t >(0);
 }
 
-void BuildMetrics::TimingMetrics::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::TimingMetrics::SerializeToOstream(OutputStream* output__) const {
   WriteVarint64(output__, 1, cpu_time_in_ms_);
   WriteVarint64(output__, 2, wall_time_in_ms_);
   WriteVarint64(output__, 3, analysis_phase_time_in_ms_);
@@ -9968,7 +9969,7 @@
   num_builds_ = static_cast< int32_t >(0);
 }
 
-void BuildMetrics::CumulativeMetrics::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::CumulativeMetrics::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 11, num_analyses_);
   WriteVarint32SignExtended(output__, 12, num_builds_);
 }
@@ -10002,7 +10003,7 @@
   count_ = static_cast< int32_t >(0);
 }
 
-void BuildMetrics::ArtifactMetrics::FilesMetric::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::ArtifactMetrics::FilesMetric::SerializeToOstream(OutputStream* output__) const {
   WriteVarint64(output__, 1, size_in_bytes_);
   WriteVarint32SignExtended(output__, 2, count_);
 }
@@ -10036,7 +10037,7 @@
   has_top_level_artifacts_ = false;
 }
 
-void BuildMetrics::ArtifactMetrics::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::ArtifactMetrics::SerializeToOstream(OutputStream* output__) const {
   if (has_source_artifacts_read_) {
     WriteLengthDelimited(output__, 2,
                          source_artifacts_read_.ByteSizeLong());
@@ -10105,7 +10106,7 @@
   count_ = static_cast< int64_t >(0);
 }
 
-void BuildMetrics::EvaluationStat::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::EvaluationStat::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, skyfunction_name_);
   WriteVarint64(output__, 2, count_);
 }
@@ -10141,7 +10142,7 @@
   action_count_ = static_cast< uint64_t >(0);
 }
 
-void BuildMetrics::BuildGraphMetrics::RuleClassCount::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::BuildGraphMetrics::RuleClassCount::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, key_);
   WriteString(output__, 2, rule_class_);
   WriteVarint64(output__, 3, count_);
@@ -10193,7 +10194,7 @@
   action_count_ = static_cast< uint64_t >(0);
 }
 
-void BuildMetrics::BuildGraphMetrics::AspectCount::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::BuildGraphMetrics::AspectCount::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, key_);
   WriteString(output__, 2, aspect_name_);
   WriteVarint64(output__, 3, count_);
@@ -10264,7 +10265,7 @@
   has_aspect_ = false;
 }
 
-void BuildMetrics::BuildGraphMetrics::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::BuildGraphMetrics::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, action_lookup_value_count_);
   WriteVarint32SignExtended(output__, 5, action_lookup_value_count_not_including_aspects_);
   WriteVarint32SignExtended(output__, 2, action_count_);
@@ -10505,7 +10506,7 @@
   last_action_start_time_in_ms_ = static_cast< int64_t >(0);
 }
 
-void BuildMetrics::WorkerMetrics::WorkerStats::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::WorkerMetrics::WorkerStats::SerializeToOstream(OutputStream* output__) const {
   WriteVarint64(output__, 1, collect_time_in_ms_);
   WriteVarint32SignExtended(output__, 2, worker_memory_in_kb_);
   WriteVarint32SignExtended(output__, 4, prior_worker_memory_in_kb_);
@@ -10574,7 +10575,7 @@
   has_worker_stats_ = false;
 }
 
-void BuildMetrics::WorkerMetrics::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::WorkerMetrics::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, worker_id_);
   for (const auto& elem : worker_ids_) {
     WriteVarint32(output__, 8, elem);
@@ -10729,7 +10730,7 @@
   peak_packets_recv_per_sec_ = static_cast< uint64_t >(0);
 }
 
-void BuildMetrics::NetworkMetrics::SystemNetworkStats::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::NetworkMetrics::SystemNetworkStats::SerializeToOstream(OutputStream* output__) const {
   WriteVarint64(output__, 1, bytes_sent_);
   WriteVarint64(output__, 2, bytes_recv_);
   WriteVarint64(output__, 3, packets_sent_);
@@ -10808,7 +10809,7 @@
   has_system_network_stats_ = false;
 }
 
-void BuildMetrics::NetworkMetrics::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::NetworkMetrics::SerializeToOstream(OutputStream* output__) const {
   if (has_system_network_stats_) {
     WriteLengthDelimited(output__, 1,
                          system_network_stats_.ByteSizeLong());
@@ -10854,7 +10855,7 @@
   alive_count_ = static_cast< int64_t >(0);
 }
 
-void BuildMetrics::WorkerPoolMetrics::WorkerPoolStats::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::WorkerPoolMetrics::WorkerPoolStats::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, hash_);
   WriteString(output__, 2, mnemonic_);
   WriteVarint64(output__, 3, created_count_);
@@ -10949,7 +10950,7 @@
   has_worker_pool_stats_ = false;
 }
 
-void BuildMetrics::WorkerPoolMetrics::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::WorkerPoolMetrics::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : worker_pool_stats_) {
     if (has_worker_pool_stats_) {
       WriteLengthDelimited(output__, 1,
@@ -10991,7 +10992,7 @@
   remote_wins_ = static_cast< int32_t >(0);
 }
 
-void BuildMetrics::DynamicExecutionMetrics::RaceStatistics::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::DynamicExecutionMetrics::RaceStatistics::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, mnemonic_);
   WriteString(output__, 2, local_runner_);
   WriteString(output__, 3, remote_runner_);
@@ -11046,7 +11047,7 @@
   has_race_statistics_ = false;
 }
 
-void BuildMetrics::DynamicExecutionMetrics::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::DynamicExecutionMetrics::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : race_statistics_) {
     if (has_race_statistics_) {
       WriteLengthDelimited(output__, 1,
@@ -11093,7 +11094,7 @@
   has_dynamic_execution_metrics_ = false;
 }
 
-void BuildMetrics::SerializeToOstream(std::ostream* output__) const {
+void BuildMetrics::SerializeToOstream(OutputStream* output__) const {
   if (has_action_summary_) {
     WriteLengthDelimited(output__, 1,
                          action_summary_.ByteSizeLong());
@@ -11272,7 +11273,7 @@
   has_log_ = false;
 }
 
-void BuildToolLogs::SerializeToOstream(std::ostream* output__) const {
+void BuildToolLogs::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : log_) {
     if (has_log_) {
       WriteLengthDelimited(output__, 1,
@@ -11308,7 +11309,7 @@
   has_convenience_symlinks_ = false;
 }
 
-void ConvenienceSymlinksIdentified::SerializeToOstream(std::ostream* output__) const {
+void ConvenienceSymlinksIdentified::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : convenience_symlinks_) {
     if (has_convenience_symlinks_) {
       WriteLengthDelimited(output__, 1,
@@ -11347,7 +11348,7 @@
   has_target_ = false;
 }
 
-void ConvenienceSymlink::SerializeToOstream(std::ostream* output__) const {
+void ConvenienceSymlink::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, path_);
   WriteVarint32SignExtended(output__, 2, static_cast<int32_t>(action_));
   WriteString(output__, 3, target_);
@@ -11391,7 +11392,7 @@
   should_exec_ = static_cast< bool >(0);
 }
 
-void ExecRequestConstructed::SerializeToOstream(std::ostream* output__) const {
+void ExecRequestConstructed::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, working_directory_);
   for (const auto& elem : argv_) {
     WriteString(output__, 2, elem);
@@ -11476,7 +11477,7 @@
   has_value_ = false;
 }
 
-void EnvironmentVariable::SerializeToOstream(std::ostream* output__) const {
+void EnvironmentVariable::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   WriteString(output__, 2, value_);
 }
@@ -11535,7 +11536,7 @@
   has_exec_request_ = false;
 }
 
-void BuildEvent::SerializeToOstream(std::ostream* output__) const {
+void BuildEvent::SerializeToOstream(OutputStream* output__) const {
   if (has_id_) {
     WriteLengthDelimited(output__, 1,
                          id_.ByteSizeLong());
diff --git a/src/build_event_stream.pb.h b/src/build_event_stream.pb.h
index 21fc776..01fe674 100644
--- a/src/build_event_stream.pb.h
+++ b/src/build_event_stream.pb.h
@@ -1,14 +1,17 @@
 // This file is auto-generated by generate_proto_header.py, do not edit
 
+// clang-format off
+
 #ifndef NINJA_BUILD_EVENT_STREAM_PB_H
 #define NINJA_BUILD_EVENT_STREAM_PB_H
 
 #include <inttypes.h>
 
-#include <iosfwd>
 #include <string>
 #include <vector>
 
+struct OutputStream;
+
 namespace bes {
 namespace google {
 namespace protobuf {
@@ -207,7 +210,7 @@
   Any(Any&&) = default;
   Any& operator=(const Any&) = default;
   Any& operator=(Any&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_type_url() {
@@ -236,7 +239,7 @@
   Duration(Duration&&) = default;
   Duration& operator=(const Duration&) = default;
   Duration& operator=(Duration&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   int64_t* mutable_seconds() {
@@ -265,7 +268,7 @@
   Timestamp(Timestamp&&) = default;
   Timestamp& operator=(const Timestamp&) = default;
   Timestamp& operator=(Timestamp&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   int64_t* mutable_seconds() {
@@ -305,7 +308,7 @@
   PackageLoadMetrics(PackageLoadMetrics&&) = default;
   PackageLoadMetrics& operator=(const PackageLoadMetrics&) = default;
   PackageLoadMetrics& operator=(PackageLoadMetrics&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -366,7 +369,7 @@
     MissDetail(MissDetail&&) = default;
     MissDetail& operator=(const MissDetail&) = default;
     MissDetail& operator=(MissDetail&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     ::bes::blaze::ActionCacheStatistics::MissReason* mutable_reason() {
@@ -398,7 +401,7 @@
   ActionCacheStatistics(ActionCacheStatistics&&) = default;
   ActionCacheStatistics& operator=(const ActionCacheStatistics&) = default;
   ActionCacheStatistics& operator=(ActionCacheStatistics&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   uint64_t* mutable_size_in_bytes() {
@@ -474,7 +477,7 @@
   CommandLine(CommandLine&&) = default;
   CommandLine& operator=(const CommandLine&) = default;
   CommandLine& operator=(CommandLine&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_command_line_label() {
@@ -497,7 +500,7 @@
   ChunkList(ChunkList&&) = default;
   ChunkList& operator=(const ChunkList&) = default;
   ChunkList& operator=(ChunkList&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< std::string >* mutable_chunk() {
@@ -516,7 +519,7 @@
   OptionList(OptionList&&) = default;
   OptionList& operator=(const OptionList&) = default;
   OptionList& operator=(OptionList&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::bes::command_line::Option >* mutable_option() {
@@ -538,7 +541,7 @@
   CommandLineSection(CommandLineSection&&) = default;
   CommandLineSection& operator=(const CommandLineSection&) = default;
   CommandLineSection& operator=(CommandLineSection&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_section_label() {
@@ -572,7 +575,7 @@
   Option(Option&&) = default;
   Option& operator=(const Option&) = default;
   Option& operator=(Option&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_combined_form() {
@@ -630,7 +633,7 @@
   FileDescriptorSet(FileDescriptorSet&&) = default;
   FileDescriptorSet& operator=(const FileDescriptorSet&) = default;
   FileDescriptorSet& operator=(FileDescriptorSet&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::bes::google::protobuf::FileDescriptorProto >* mutable_file() {
@@ -695,7 +698,7 @@
   FeatureSet(FeatureSet&&) = default;
   FeatureSet& operator=(const FeatureSet&) = default;
   FeatureSet& operator=(FeatureSet&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::google::protobuf::FeatureSet::FieldPresence* mutable_field_presence() {
@@ -784,7 +787,7 @@
   FileOptions(FileOptions&&) = default;
   FileOptions& operator=(const FileOptions&) = default;
   FileOptions& operator=(FileOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_java_package() {
@@ -910,7 +913,7 @@
     Location(Location&&) = default;
     Location& operator=(const Location&) = default;
     Location& operator=(Location&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::vector< int32_t >* mutable_path() {
@@ -950,7 +953,7 @@
   SourceCodeInfo(SourceCodeInfo&&) = default;
   SourceCodeInfo& operator=(const SourceCodeInfo&) = default;
   SourceCodeInfo& operator=(SourceCodeInfo&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::bes::google::protobuf::SourceCodeInfo::Location >* mutable_location() {
@@ -992,7 +995,7 @@
   FileDescriptorProto(FileDescriptorProto&&) = default;
   FileDescriptorProto& operator=(const FileDescriptorProto&) = default;
   FileDescriptorProto& operator=(FileDescriptorProto&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -1085,7 +1088,7 @@
     Declaration(Declaration&&) = default;
     Declaration& operator=(const Declaration&) = default;
     Declaration& operator=(Declaration&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     int32_t* mutable_number() {
@@ -1128,7 +1131,7 @@
   ExtensionRangeOptions(ExtensionRangeOptions&&) = default;
   ExtensionRangeOptions& operator=(const ExtensionRangeOptions&) = default;
   ExtensionRangeOptions& operator=(ExtensionRangeOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::bes::google::protobuf::UninterpretedOption >* mutable_uninterpreted_option() {
@@ -1172,7 +1175,7 @@
   MessageOptions(MessageOptions&&) = default;
   MessageOptions& operator=(const MessageOptions&) = default;
   MessageOptions& operator=(MessageOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   bool* mutable_message_set_wire_format() {
@@ -1224,7 +1227,7 @@
     ExtensionRange(ExtensionRange&&) = default;
     ExtensionRange& operator=(const ExtensionRange&) = default;
     ExtensionRange& operator=(ExtensionRange&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     int32_t* mutable_start() {
@@ -1253,7 +1256,7 @@
     ReservedRange(ReservedRange&&) = default;
     ReservedRange& operator=(const ReservedRange&) = default;
     ReservedRange& operator=(ReservedRange&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     int32_t* mutable_start() {
@@ -1293,7 +1296,7 @@
   DescriptorProto(DescriptorProto&&) = default;
   DescriptorProto& operator=(const DescriptorProto&) = default;
   DescriptorProto& operator=(DescriptorProto&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -1390,7 +1393,7 @@
     EditionDefault(EditionDefault&&) = default;
     EditionDefault& operator=(const EditionDefault&) = default;
     EditionDefault& operator=(EditionDefault&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     ::bes::google::protobuf::Edition* mutable_edition() {
@@ -1419,7 +1422,7 @@
     FeatureSupport(FeatureSupport&&) = default;
     FeatureSupport& operator=(const FeatureSupport&) = default;
     FeatureSupport& operator=(FeatureSupport&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     ::bes::google::protobuf::Edition* mutable_edition_introduced() {
@@ -1477,7 +1480,7 @@
   FieldOptions(FieldOptions&&) = default;
   FieldOptions& operator=(const FieldOptions&) = default;
   FieldOptions& operator=(FieldOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::google::protobuf::FieldOptions::CType* mutable_ctype() {
@@ -1606,7 +1609,7 @@
   FieldDescriptorProto(FieldDescriptorProto&&) = default;
   FieldDescriptorProto& operator=(const FieldDescriptorProto&) = default;
   FieldDescriptorProto& operator=(FieldDescriptorProto&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -1675,7 +1678,7 @@
   OneofOptions(OneofOptions&&) = default;
   OneofOptions& operator=(const OneofOptions&) = default;
   OneofOptions& operator=(OneofOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::google::protobuf::FeatureSet* mutable_features() {
@@ -1699,7 +1702,7 @@
   OneofDescriptorProto(OneofDescriptorProto&&) = default;
   OneofDescriptorProto& operator=(const OneofDescriptorProto&) = default;
   OneofDescriptorProto& operator=(OneofDescriptorProto&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -1729,7 +1732,7 @@
   EnumOptions(EnumOptions&&) = default;
   EnumOptions& operator=(const EnumOptions&) = default;
   EnumOptions& operator=(EnumOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   bool* mutable_allow_alias() {
@@ -1769,7 +1772,7 @@
     EnumReservedRange(EnumReservedRange&&) = default;
     EnumReservedRange& operator=(const EnumReservedRange&) = default;
     EnumReservedRange& operator=(EnumReservedRange&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     int32_t* mutable_start() {
@@ -1799,7 +1802,7 @@
   EnumDescriptorProto(EnumDescriptorProto&&) = default;
   EnumDescriptorProto& operator=(const EnumDescriptorProto&) = default;
   EnumDescriptorProto& operator=(EnumDescriptorProto&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -1845,7 +1848,7 @@
   EnumValueOptions(EnumValueOptions&&) = default;
   EnumValueOptions& operator=(const EnumValueOptions&) = default;
   EnumValueOptions& operator=(EnumValueOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   bool* mutable_deprecated() {
@@ -1885,7 +1888,7 @@
   EnumValueDescriptorProto(EnumValueDescriptorProto&&) = default;
   EnumValueDescriptorProto& operator=(const EnumValueDescriptorProto&) = default;
   EnumValueDescriptorProto& operator=(EnumValueDescriptorProto&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -1916,7 +1919,7 @@
   ServiceOptions(ServiceOptions&&) = default;
   ServiceOptions& operator=(const ServiceOptions&) = default;
   ServiceOptions& operator=(ServiceOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::google::protobuf::FeatureSet* mutable_features() {
@@ -1947,7 +1950,7 @@
   ServiceDescriptorProto(ServiceDescriptorProto&&) = default;
   ServiceDescriptorProto& operator=(const ServiceDescriptorProto&) = default;
   ServiceDescriptorProto& operator=(ServiceDescriptorProto&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -1986,7 +1989,7 @@
   MethodOptions(MethodOptions&&) = default;
   MethodOptions& operator=(const MethodOptions&) = default;
   MethodOptions& operator=(MethodOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   bool* mutable_deprecated() {
@@ -2028,7 +2031,7 @@
   MethodDescriptorProto(MethodDescriptorProto&&) = default;
   MethodDescriptorProto& operator=(const MethodDescriptorProto&) = default;
   MethodDescriptorProto& operator=(MethodDescriptorProto&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -2073,7 +2076,7 @@
     NamePart(NamePart&&) = default;
     NamePart& operator=(const NamePart&) = default;
     NamePart& operator=(NamePart&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_name_part() {
@@ -2107,7 +2110,7 @@
   UninterpretedOption(UninterpretedOption&&) = default;
   UninterpretedOption& operator=(const UninterpretedOption&) = default;
   UninterpretedOption& operator=(UninterpretedOption&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::bes::google::protobuf::UninterpretedOption::NamePart >* mutable_name() {
@@ -2160,7 +2163,7 @@
     FeatureSetEditionDefault(FeatureSetEditionDefault&&) = default;
     FeatureSetEditionDefault& operator=(const FeatureSetEditionDefault&) = default;
     FeatureSetEditionDefault& operator=(FeatureSetEditionDefault&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     ::bes::google::protobuf::Edition* mutable_edition() {
@@ -2189,7 +2192,7 @@
   FeatureSetDefaults(FeatureSetDefaults&&) = default;
   FeatureSetDefaults& operator=(const FeatureSetDefaults&) = default;
   FeatureSetDefaults& operator=(FeatureSetDefaults&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::bes::google::protobuf::FeatureSetDefaults::FeatureSetEditionDefault >* mutable_defaults() {
@@ -2232,7 +2235,7 @@
     Annotation(Annotation&&) = default;
     Annotation& operator=(const Annotation&) = default;
     Annotation& operator=(Annotation&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::vector< int32_t >* mutable_path() {
@@ -2270,7 +2273,7 @@
   GeneratedCodeInfo(GeneratedCodeInfo&&) = default;
   GeneratedCodeInfo& operator=(const GeneratedCodeInfo&) = default;
   GeneratedCodeInfo& operator=(GeneratedCodeInfo&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::bes::google::protobuf::GeneratedCodeInfo::Annotation >* mutable_annotation() {
@@ -2291,7 +2294,7 @@
   FailureDetailMetadata(FailureDetailMetadata&&) = default;
   FailureDetailMetadata& operator=(const FailureDetailMetadata&) = default;
   FailureDetailMetadata& operator=(FailureDetailMetadata&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   uint32_t* mutable_exit_code() {
@@ -2314,7 +2317,7 @@
   ActionCache(ActionCache&&) = default;
   ActionCache& operator=(const ActionCache&) = default;
   ActionCache& operator=(ActionCache&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::ActionCache::Code* mutable_code() {
@@ -2350,7 +2353,7 @@
   ActionQuery(ActionQuery&&) = default;
   ActionQuery& operator=(const ActionQuery&) = default;
   ActionQuery& operator=(ActionQuery&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::ActionQuery::Code* mutable_code() {
@@ -2378,7 +2381,7 @@
   ActionRewinding(ActionRewinding&&) = default;
   ActionRewinding& operator=(const ActionRewinding&) = default;
   ActionRewinding& operator=(ActionRewinding&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::ActionRewinding::Code* mutable_code() {
@@ -2421,7 +2424,7 @@
   Analysis(Analysis&&) = default;
   Analysis& operator=(const Analysis&) = default;
   Analysis& operator=(Analysis&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::Analysis::Code* mutable_code() {
@@ -2456,7 +2459,7 @@
   BuildConfiguration(BuildConfiguration&&) = default;
   BuildConfiguration& operator=(const BuildConfiguration&) = default;
   BuildConfiguration& operator=(BuildConfiguration&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::BuildConfiguration::Code* mutable_code() {
@@ -2494,7 +2497,7 @@
   BuildProgress(BuildProgress&&) = default;
   BuildProgress& operator=(const BuildProgress&) = default;
   BuildProgress& operator=(BuildProgress&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::BuildProgress::Code* mutable_code() {
@@ -2518,7 +2521,7 @@
   BuildReport(BuildReport&&) = default;
   BuildReport& operator=(const BuildReport&) = default;
   BuildReport& operator=(BuildReport&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::BuildReport::Code* mutable_code() {
@@ -2541,7 +2544,7 @@
   CanonicalizeFlags(CanonicalizeFlags&&) = default;
   CanonicalizeFlags& operator=(const CanonicalizeFlags&) = default;
   CanonicalizeFlags& operator=(CanonicalizeFlags&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::CanonicalizeFlags::Code* mutable_code() {
@@ -2573,7 +2576,7 @@
   CleanCommand(CleanCommand&&) = default;
   CleanCommand& operator=(const CleanCommand&) = default;
   CleanCommand& operator=(CleanCommand&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::CleanCommand::Code* mutable_code() {
@@ -2596,7 +2599,7 @@
   ClientEnvironment(ClientEnvironment&&) = default;
   ClientEnvironment& operator=(const ClientEnvironment&) = default;
   ClientEnvironment& operator=(ClientEnvironment&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::ClientEnvironment::Code* mutable_code() {
@@ -2631,7 +2634,7 @@
   Command(Command&&) = default;
   Command& operator=(const Command&) = default;
   Command& operator=(Command&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::Command::Code* mutable_code() {
@@ -2655,7 +2658,7 @@
   ConfigCommand(ConfigCommand&&) = default;
   ConfigCommand& operator=(const ConfigCommand&) = default;
   ConfigCommand& operator=(ConfigCommand&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::ConfigCommand::Code* mutable_code() {
@@ -2689,7 +2692,7 @@
   ConfigurableQuery(ConfigurableQuery&&) = default;
   ConfigurableQuery& operator=(const ConfigurableQuery&) = default;
   ConfigurableQuery& operator=(ConfigurableQuery&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::ConfigurableQuery::Code* mutable_code() {
@@ -2722,7 +2725,7 @@
   CppCompile(CppCompile&&) = default;
   CppCompile& operator=(const CppCompile&) = default;
   CppCompile& operator=(CppCompile&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::CppCompile::Code* mutable_code() {
@@ -2746,7 +2749,7 @@
   CppLink(CppLink&&) = default;
   CppLink& operator=(const CppLink&) = default;
   CppLink& operator=(CppLink&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::CppLink::Code* mutable_code() {
@@ -2773,7 +2776,7 @@
   Crash(Crash&&) = default;
   Crash& operator=(const Crash&) = default;
   Crash& operator=(Crash&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::Crash::Code* mutable_code() {
@@ -2805,7 +2808,7 @@
   CrashOptions(CrashOptions&&) = default;
   CrashOptions& operator=(const CrashOptions&) = default;
   CrashOptions& operator=(CrashOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::CrashOptions::Code* mutable_code() {
@@ -2828,7 +2831,7 @@
   DiffAwareness(DiffAwareness&&) = default;
   DiffAwareness& operator=(const DiffAwareness&) = default;
   DiffAwareness& operator=(DiffAwareness&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::DiffAwareness::Code* mutable_code() {
@@ -2856,7 +2859,7 @@
   DumpCommand(DumpCommand&&) = default;
   DumpCommand& operator=(const DumpCommand&) = default;
   DumpCommand& operator=(DumpCommand&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::DumpCommand::Code* mutable_code() {
@@ -2882,7 +2885,7 @@
   DynamicExecution(DynamicExecution&&) = default;
   DynamicExecution& operator=(const DynamicExecution&) = default;
   DynamicExecution& operator=(DynamicExecution&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::DynamicExecution::Code* mutable_code() {
@@ -2942,7 +2945,7 @@
   Execution(Execution&&) = default;
   Execution& operator=(const Execution&) = default;
   Execution& operator=(Execution&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::Execution::Code* mutable_code() {
@@ -2973,7 +2976,7 @@
   ExecutionOptions(ExecutionOptions&&) = default;
   ExecutionOptions& operator=(const ExecutionOptions&) = default;
   ExecutionOptions& operator=(ExecutionOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::ExecutionOptions::Code* mutable_code() {
@@ -3002,7 +3005,7 @@
   ExternalDeps(ExternalDeps&&) = default;
   ExternalDeps& operator=(const ExternalDeps&) = default;
   ExternalDeps& operator=(ExternalDeps&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::ExternalDeps::Code* mutable_code() {
@@ -3028,7 +3031,7 @@
   ExternalRepository(ExternalRepository&&) = default;
   ExternalRepository& operator=(const ExternalRepository&) = default;
   ExternalRepository& operator=(ExternalRepository&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::ExternalRepository::Code* mutable_code() {
@@ -3058,7 +3061,7 @@
   FailAction(FailAction&&) = default;
   FailAction& operator=(const FailAction&) = default;
   FailAction& operator=(FailAction&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::FailAction::Code* mutable_code() {
@@ -3084,7 +3087,7 @@
   FetchCommand(FetchCommand&&) = default;
   FetchCommand& operator=(const FetchCommand&) = default;
   FetchCommand& operator=(FetchCommand&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::FetchCommand::Code* mutable_code() {
@@ -3111,7 +3114,7 @@
   Filesystem(Filesystem&&) = default;
   Filesystem& operator=(const Filesystem&) = default;
   Filesystem& operator=(Filesystem&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::Filesystem::Code* mutable_code() {
@@ -3137,7 +3140,7 @@
   GrpcServer(GrpcServer&&) = default;
   GrpcServer& operator=(const GrpcServer&) = default;
   GrpcServer& operator=(GrpcServer&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::GrpcServer::Code* mutable_code() {
@@ -3161,7 +3164,7 @@
   HelpCommand(HelpCommand&&) = default;
   HelpCommand& operator=(const HelpCommand&) = default;
   HelpCommand& operator=(HelpCommand&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::HelpCommand::Code* mutable_code() {
@@ -3214,7 +3217,7 @@
   PackageLoading(PackageLoading&&) = default;
   PackageLoading& operator=(const PackageLoading&) = default;
   PackageLoading& operator=(PackageLoading&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::PackageLoading::Code* mutable_code() {
@@ -3247,7 +3250,7 @@
   IncludeScanning(IncludeScanning&&) = default;
   IncludeScanning& operator=(const IncludeScanning&) = default;
   IncludeScanning& operator=(IncludeScanning&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::IncludeScanning::Code* mutable_code() {
@@ -3278,7 +3281,7 @@
   InfoCommand(InfoCommand&&) = default;
   InfoCommand& operator=(const InfoCommand&) = default;
   InfoCommand& operator=(InfoCommand&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::InfoCommand::Code* mutable_code() {
@@ -3315,7 +3318,7 @@
   Interrupted(Interrupted&&) = default;
   Interrupted& operator=(const Interrupted&) = default;
   Interrupted& operator=(Interrupted&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::Interrupted::Code* mutable_code() {
@@ -3341,7 +3344,7 @@
   JavaCompile(JavaCompile&&) = default;
   JavaCompile& operator=(const JavaCompile&) = default;
   JavaCompile& operator=(JavaCompile&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::JavaCompile::Code* mutable_code() {
@@ -3365,7 +3368,7 @@
   LocalExecution(LocalExecution&&) = default;
   LocalExecution& operator=(const LocalExecution&) = default;
   LocalExecution& operator=(LocalExecution&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::LocalExecution::Code* mutable_code() {
@@ -3390,7 +3393,7 @@
   LtoAction(LtoAction&&) = default;
   LtoAction& operator=(const LtoAction&) = default;
   LtoAction& operator=(LtoAction&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::LtoAction::Code* mutable_code() {
@@ -3414,7 +3417,7 @@
   MemoryOptions(MemoryOptions&&) = default;
   MemoryOptions& operator=(const MemoryOptions&) = default;
   MemoryOptions& operator=(MemoryOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::MemoryOptions::Code* mutable_code() {
@@ -3442,7 +3445,7 @@
   MobileInstall(MobileInstall&&) = default;
   MobileInstall& operator=(const MobileInstall&) = default;
   MobileInstall& operator=(MobileInstall&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::MobileInstall::Code* mutable_code() {
@@ -3469,7 +3472,7 @@
   ModCommand(ModCommand&&) = default;
   ModCommand& operator=(const ModCommand&) = default;
   ModCommand& operator=(ModCommand&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::ModCommand::Code* mutable_code() {
@@ -3493,7 +3496,7 @@
   NinjaAction(NinjaAction&&) = default;
   NinjaAction& operator=(const NinjaAction&) = default;
   NinjaAction& operator=(NinjaAction&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::NinjaAction::Code* mutable_code() {
@@ -3517,7 +3520,7 @@
   PackageOptions(PackageOptions&&) = default;
   PackageOptions& operator=(const PackageOptions&) = default;
   PackageOptions& operator=(PackageOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::PackageOptions::Code* mutable_code() {
@@ -3543,7 +3546,7 @@
   PrintActionCommand(PrintActionCommand&&) = default;
   PrintActionCommand& operator=(const PrintActionCommand&) = default;
   PrintActionCommand& operator=(PrintActionCommand&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::PrintActionCommand::Code* mutable_code() {
@@ -3567,7 +3570,7 @@
   ProfileCommand(ProfileCommand&&) = default;
   ProfileCommand& operator=(const ProfileCommand&) = default;
   ProfileCommand& operator=(ProfileCommand&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::ProfileCommand::Code* mutable_code() {
@@ -3624,7 +3627,7 @@
   Query(Query&&) = default;
   Query& operator=(const Query&) = default;
   Query& operator=(Query&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::Query::Code* mutable_code() {
@@ -3648,7 +3651,7 @@
   RemoteAnalysisCaching(RemoteAnalysisCaching&&) = default;
   RemoteAnalysisCaching& operator=(const RemoteAnalysisCaching&) = default;
   RemoteAnalysisCaching& operator=(RemoteAnalysisCaching&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::RemoteAnalysisCaching::Code* mutable_code() {
@@ -3687,7 +3690,7 @@
   RemoteExecution(RemoteExecution&&) = default;
   RemoteExecution& operator=(const RemoteExecution&) = default;
   RemoteExecution& operator=(RemoteExecution&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::RemoteExecution::Code* mutable_code() {
@@ -3714,7 +3717,7 @@
   RemoteOptions(RemoteOptions&&) = default;
   RemoteOptions& operator=(const RemoteOptions&) = default;
   RemoteOptions& operator=(RemoteOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::RemoteOptions::Code* mutable_code() {
@@ -3751,7 +3754,7 @@
   RunCommand(RunCommand&&) = default;
   RunCommand& operator=(const RunCommand&) = default;
   RunCommand& operator=(RunCommand&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::RunCommand::Code* mutable_code() {
@@ -3786,7 +3789,7 @@
   Sandbox(Sandbox&&) = default;
   Sandbox& operator=(const Sandbox&) = default;
   Sandbox& operator=(Sandbox&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::Sandbox::Code* mutable_code() {
@@ -3811,7 +3814,7 @@
   Skyfocus(Skyfocus&&) = default;
   Skyfocus& operator=(const Skyfocus&) = default;
   Skyfocus& operator=(Skyfocus&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::Skyfocus::Code* mutable_code() {
@@ -3852,7 +3855,7 @@
   Spawn(Spawn&&) = default;
   Spawn& operator=(const Spawn&) = default;
   Spawn& operator=(Spawn&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::Spawn::Code* mutable_code() {
@@ -3886,7 +3889,7 @@
   StarlarkAction(StarlarkAction&&) = default;
   StarlarkAction& operator=(const StarlarkAction&) = default;
   StarlarkAction& operator=(StarlarkAction&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::StarlarkAction::Code* mutable_code() {
@@ -3918,7 +3921,7 @@
   StarlarkLoading(StarlarkLoading&&) = default;
   StarlarkLoading& operator=(const StarlarkLoading&) = default;
   StarlarkLoading& operator=(StarlarkLoading&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::StarlarkLoading::Code* mutable_code() {
@@ -3946,7 +3949,7 @@
   SymlinkAction(SymlinkAction&&) = default;
   SymlinkAction& operator=(const SymlinkAction&) = default;
   SymlinkAction& operator=(SymlinkAction&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::SymlinkAction::Code* mutable_code() {
@@ -3971,7 +3974,7 @@
   SymlinkForest(SymlinkForest&&) = default;
   SymlinkForest& operator=(const SymlinkForest&) = default;
   SymlinkForest& operator=(SymlinkForest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::SymlinkForest::Code* mutable_code() {
@@ -3997,7 +4000,7 @@
   SyncCommand(SyncCommand&&) = default;
   SyncCommand& operator=(const SyncCommand&) = default;
   SyncCommand& operator=(SyncCommand&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::SyncCommand::Code* mutable_code() {
@@ -4038,7 +4041,7 @@
   TargetPatterns(TargetPatterns&&) = default;
   TargetPatterns& operator=(const TargetPatterns&) = default;
   TargetPatterns& operator=(TargetPatterns&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::TargetPatterns::Code* mutable_code() {
@@ -4065,7 +4068,7 @@
   TestAction(TestAction&&) = default;
   TestAction& operator=(const TestAction&) = default;
   TestAction& operator=(TestAction&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::TestAction::Code* mutable_code() {
@@ -4090,7 +4093,7 @@
   TestCommand(TestCommand&&) = default;
   TestCommand& operator=(const TestCommand&) = default;
   TestCommand& operator=(TestCommand&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::TestCommand::Code* mutable_code() {
@@ -4119,7 +4122,7 @@
   Toolchain(Toolchain&&) = default;
   Toolchain& operator=(const Toolchain&) = default;
   Toolchain& operator=(Toolchain&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::Toolchain::Code* mutable_code() {
@@ -4142,7 +4145,7 @@
   VersionCommand(VersionCommand&&) = default;
   VersionCommand& operator=(const VersionCommand&) = default;
   VersionCommand& operator=(VersionCommand&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::VersionCommand::Code* mutable_code() {
@@ -4177,7 +4180,7 @@
   Worker(Worker&&) = default;
   Worker& operator=(const Worker&) = default;
   Worker& operator=(Worker&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::Worker::Code* mutable_code() {
@@ -4206,7 +4209,7 @@
   WorkspaceStatus(WorkspaceStatus&&) = default;
   WorkspaceStatus& operator=(const WorkspaceStatus&) = default;
   WorkspaceStatus& operator=(WorkspaceStatus&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::WorkspaceStatus::Code* mutable_code() {
@@ -4232,7 +4235,7 @@
   Workspaces(Workspaces&&) = default;
   Workspaces& operator=(const Workspaces&) = default;
   Workspaces& operator=(Workspaces&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::failure_details::Workspaces::Code* mutable_code() {
@@ -4378,7 +4381,7 @@
   FailureDetail(FailureDetail&&) = default;
   FailureDetail& operator=(const FailureDetail&) = default;
   FailureDetail& operator=(FailureDetail&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_message() {
@@ -4656,7 +4659,7 @@
   Throwable(Throwable&&) = default;
   Throwable& operator=(const Throwable&) = default;
   Throwable& operator=(Throwable&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_throwable_class() {
@@ -4690,7 +4693,7 @@
   MnemonicPolicy(MnemonicPolicy&&) = default;
   MnemonicPolicy& operator=(const MnemonicPolicy&) = default;
   MnemonicPolicy& operator=(MnemonicPolicy&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< std::string >* mutable_default_allowlist() {
@@ -4718,7 +4721,7 @@
   StrategyPolicy(StrategyPolicy&&) = default;
   StrategyPolicy& operator=(const StrategyPolicy&) = default;
   StrategyPolicy& operator=(StrategyPolicy&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::blaze::strategy_policy::MnemonicPolicy* mutable_mnemonic_policy() {
@@ -4745,7 +4748,7 @@
   StrategiesForMnemonic(StrategiesForMnemonic&&) = default;
   StrategiesForMnemonic& operator=(const StrategiesForMnemonic&) = default;
   StrategiesForMnemonic& operator=(StrategiesForMnemonic&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_mnemonic() {
@@ -4775,7 +4778,7 @@
   InvocationPolicy(InvocationPolicy&&) = default;
   InvocationPolicy& operator=(const InvocationPolicy&) = default;
   InvocationPolicy& operator=(InvocationPolicy&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::bes::blaze::invocation_policy::FlagPolicy >* mutable_flag_policies() {
@@ -4794,7 +4797,7 @@
   UseDefault(UseDefault&&) = default;
   UseDefault& operator=(const UseDefault&) = default;
   UseDefault& operator=(UseDefault&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
 };  // struct UseDefault
@@ -4811,7 +4814,7 @@
   AllowValues(AllowValues&&) = default;
   AllowValues& operator=(const AllowValues&) = default;
   AllowValues& operator=(AllowValues&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< std::string >* mutable_allowed_values() {
@@ -4843,7 +4846,7 @@
   DisallowValues(DisallowValues&&) = default;
   DisallowValues& operator=(const DisallowValues&) = default;
   DisallowValues& operator=(DisallowValues&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< std::string >* mutable_disallowed_values() {
@@ -4880,7 +4883,7 @@
   SetValue(SetValue&&) = default;
   SetValue& operator=(const SetValue&) = default;
   SetValue& operator=(SetValue&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< std::string >* mutable_flag_value() {
@@ -4914,7 +4917,7 @@
   FlagPolicy(FlagPolicy&&) = default;
   FlagPolicy& operator=(const FlagPolicy&) = default;
   FlagPolicy& operator=(FlagPolicy&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_flag_name() {
@@ -4978,7 +4981,7 @@
     UnknownBuildEventId(UnknownBuildEventId&&) = default;
     UnknownBuildEventId& operator=(const UnknownBuildEventId&) = default;
     UnknownBuildEventId& operator=(UnknownBuildEventId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_details() {
@@ -4996,7 +4999,7 @@
     ProgressId(ProgressId&&) = default;
     ProgressId& operator=(const ProgressId&) = default;
     ProgressId& operator=(ProgressId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     int32_t* mutable_opaque_count() {
@@ -5011,7 +5014,7 @@
     BuildStartedId(BuildStartedId&&) = default;
     BuildStartedId& operator=(const BuildStartedId&) = default;
     BuildStartedId& operator=(BuildStartedId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
   };  // struct BuildStartedId
@@ -5021,7 +5024,7 @@
     UnstructuredCommandLineId(UnstructuredCommandLineId&&) = default;
     UnstructuredCommandLineId& operator=(const UnstructuredCommandLineId&) = default;
     UnstructuredCommandLineId& operator=(UnstructuredCommandLineId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
   };  // struct UnstructuredCommandLineId
@@ -5034,7 +5037,7 @@
     StructuredCommandLineId(StructuredCommandLineId&&) = default;
     StructuredCommandLineId& operator=(const StructuredCommandLineId&) = default;
     StructuredCommandLineId& operator=(StructuredCommandLineId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_command_line_label() {
@@ -5049,7 +5052,7 @@
     WorkspaceStatusId(WorkspaceStatusId&&) = default;
     WorkspaceStatusId& operator=(const WorkspaceStatusId&) = default;
     WorkspaceStatusId& operator=(WorkspaceStatusId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
   };  // struct WorkspaceStatusId
@@ -5059,7 +5062,7 @@
     OptionsParsedId(OptionsParsedId&&) = default;
     OptionsParsedId& operator=(const OptionsParsedId&) = default;
     OptionsParsedId& operator=(OptionsParsedId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
   };  // struct OptionsParsedId
@@ -5072,7 +5075,7 @@
     FetchId(FetchId&&) = default;
     FetchId& operator=(const FetchId&) = default;
     FetchId& operator=(FetchId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_url() {
@@ -5090,7 +5093,7 @@
     PatternExpandedId(PatternExpandedId&&) = default;
     PatternExpandedId& operator=(const PatternExpandedId&) = default;
     PatternExpandedId& operator=(PatternExpandedId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::vector< std::string >* mutable_pattern() {
@@ -5106,7 +5109,7 @@
     WorkspaceConfigId(WorkspaceConfigId&&) = default;
     WorkspaceConfigId& operator=(const WorkspaceConfigId&) = default;
     WorkspaceConfigId& operator=(WorkspaceConfigId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
   };  // struct WorkspaceConfigId
@@ -5116,7 +5119,7 @@
     BuildMetadataId(BuildMetadataId&&) = default;
     BuildMetadataId& operator=(const BuildMetadataId&) = default;
     BuildMetadataId& operator=(BuildMetadataId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
   };  // struct BuildMetadataId
@@ -5131,7 +5134,7 @@
     TargetConfiguredId(TargetConfiguredId&&) = default;
     TargetConfiguredId& operator=(const TargetConfiguredId&) = default;
     TargetConfiguredId& operator=(TargetConfiguredId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_label() {
@@ -5154,7 +5157,7 @@
     NamedSetOfFilesId(NamedSetOfFilesId&&) = default;
     NamedSetOfFilesId& operator=(const NamedSetOfFilesId&) = default;
     NamedSetOfFilesId& operator=(NamedSetOfFilesId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_id() {
@@ -5172,7 +5175,7 @@
     ConfigurationId(ConfigurationId&&) = default;
     ConfigurationId& operator=(const ConfigurationId&) = default;
     ConfigurationId& operator=(ConfigurationId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_id() {
@@ -5194,7 +5197,7 @@
     TargetCompletedId(TargetCompletedId&&) = default;
     TargetCompletedId& operator=(const TargetCompletedId&) = default;
     TargetCompletedId& operator=(TargetCompletedId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_label() {
@@ -5225,7 +5228,7 @@
     ActionCompletedId(ActionCompletedId&&) = default;
     ActionCompletedId& operator=(const ActionCompletedId&) = default;
     ActionCompletedId& operator=(ActionCompletedId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_primary_output() {
@@ -5252,7 +5255,7 @@
     UnconfiguredLabelId(UnconfiguredLabelId&&) = default;
     UnconfiguredLabelId& operator=(const UnconfiguredLabelId&) = default;
     UnconfiguredLabelId& operator=(UnconfiguredLabelId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_label() {
@@ -5272,7 +5275,7 @@
     ConfiguredLabelId(ConfiguredLabelId&&) = default;
     ConfiguredLabelId& operator=(const ConfiguredLabelId&) = default;
     ConfiguredLabelId& operator=(ConfiguredLabelId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_label() {
@@ -5302,7 +5305,7 @@
     TestResultId(TestResultId&&) = default;
     TestResultId& operator=(const TestResultId&) = default;
     TestResultId& operator=(TestResultId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_label() {
@@ -5349,7 +5352,7 @@
     TestProgressId(TestProgressId&&) = default;
     TestProgressId& operator=(const TestProgressId&) = default;
     TestProgressId& operator=(TestProgressId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_label() {
@@ -5393,7 +5396,7 @@
     TestSummaryId(TestSummaryId&&) = default;
     TestSummaryId& operator=(const TestSummaryId&) = default;
     TestSummaryId& operator=(TestSummaryId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_label() {
@@ -5417,7 +5420,7 @@
     TargetSummaryId(TargetSummaryId&&) = default;
     TargetSummaryId& operator=(const TargetSummaryId&) = default;
     TargetSummaryId& operator=(TargetSummaryId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_label() {
@@ -5436,7 +5439,7 @@
     BuildFinishedId(BuildFinishedId&&) = default;
     BuildFinishedId& operator=(const BuildFinishedId&) = default;
     BuildFinishedId& operator=(BuildFinishedId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
   };  // struct BuildFinishedId
@@ -5446,7 +5449,7 @@
     BuildToolLogsId(BuildToolLogsId&&) = default;
     BuildToolLogsId& operator=(const BuildToolLogsId&) = default;
     BuildToolLogsId& operator=(BuildToolLogsId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
   };  // struct BuildToolLogsId
@@ -5456,7 +5459,7 @@
     BuildMetricsId(BuildMetricsId&&) = default;
     BuildMetricsId& operator=(const BuildMetricsId&) = default;
     BuildMetricsId& operator=(BuildMetricsId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
   };  // struct BuildMetricsId
@@ -5466,7 +5469,7 @@
     ConvenienceSymlinksIdentifiedId(ConvenienceSymlinksIdentifiedId&&) = default;
     ConvenienceSymlinksIdentifiedId& operator=(const ConvenienceSymlinksIdentifiedId&) = default;
     ConvenienceSymlinksIdentifiedId& operator=(ConvenienceSymlinksIdentifiedId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
   };  // struct ConvenienceSymlinksIdentifiedId
@@ -5476,7 +5479,7 @@
     ExecRequestId(ExecRequestId&&) = default;
     ExecRequestId& operator=(const ExecRequestId&) = default;
     ExecRequestId& operator=(ExecRequestId&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
   };  // struct ExecRequestId
@@ -5542,7 +5545,7 @@
   BuildEventId(BuildEventId&&) = default;
   BuildEventId& operator=(const BuildEventId&) = default;
   BuildEventId& operator=(BuildEventId&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::build_event_stream::BuildEventId::UnknownBuildEventId* mutable_unknown() {
@@ -5669,7 +5672,7 @@
   Progress(Progress&&) = default;
   Progress& operator=(const Progress&) = default;
   Progress& operator=(Progress&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_stdout() {
@@ -5709,7 +5712,7 @@
   Aborted(Aborted&&) = default;
   Aborted& operator=(const Aborted&) = default;
   Aborted& operator=(Aborted&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::build_event_stream::Aborted::AbortReason* mutable_reason() {
@@ -5748,7 +5751,7 @@
   BuildStarted(BuildStarted&&) = default;
   BuildStarted& operator=(const BuildStarted&) = default;
   BuildStarted& operator=(BuildStarted&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_uuid() {
@@ -5805,7 +5808,7 @@
   WorkspaceConfig(WorkspaceConfig&&) = default;
   WorkspaceConfig& operator=(const WorkspaceConfig&) = default;
   WorkspaceConfig& operator=(WorkspaceConfig&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_local_exec_root() {
@@ -5823,7 +5826,7 @@
   UnstructuredCommandLine(UnstructuredCommandLine&&) = default;
   UnstructuredCommandLine& operator=(const UnstructuredCommandLine&) = default;
   UnstructuredCommandLine& operator=(UnstructuredCommandLine&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< std::string >* mutable_args() {
@@ -5852,7 +5855,7 @@
   OptionsParsed(OptionsParsed&&) = default;
   OptionsParsed& operator=(const OptionsParsed&) = default;
   OptionsParsed& operator=(OptionsParsed&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< std::string >* mutable_startup_options() {
@@ -5898,7 +5901,7 @@
   Fetch(Fetch&&) = default;
   Fetch& operator=(const Fetch&) = default;
   Fetch& operator=(Fetch&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   bool* mutable_success() {
@@ -5919,7 +5922,7 @@
     Item(Item&&) = default;
     Item& operator=(const Item&) = default;
     Item& operator=(Item&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_key() {
@@ -5941,7 +5944,7 @@
   WorkspaceStatus(WorkspaceStatus&&) = default;
   WorkspaceStatus& operator=(const WorkspaceStatus&) = default;
   WorkspaceStatus& operator=(WorkspaceStatus&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::bes::build_event_stream::WorkspaceStatus::Item >* mutable_item() {
@@ -5962,7 +5965,7 @@
     MetadataEntry(MetadataEntry&&) = default;
     MetadataEntry& operator=(const MetadataEntry&) = default;
     MetadataEntry& operator=(MetadataEntry&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_key() {
@@ -5984,7 +5987,7 @@
   BuildMetadata(BuildMetadata&&) = default;
   BuildMetadata& operator=(const BuildMetadata&) = default;
   BuildMetadata& operator=(BuildMetadata&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::bes::build_event_stream::BuildMetadata::MetadataEntry >* mutable_metadata() {
@@ -6005,7 +6008,7 @@
     MakeVariableEntry(MakeVariableEntry&&) = default;
     MakeVariableEntry& operator=(const MakeVariableEntry&) = default;
     MakeVariableEntry& operator=(MakeVariableEntry&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_key() {
@@ -6035,7 +6038,7 @@
   Configuration(Configuration&&) = default;
   Configuration& operator=(const Configuration&) = default;
   Configuration& operator=(Configuration&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_mnemonic() {
@@ -6076,7 +6079,7 @@
     TestSuiteExpansion(TestSuiteExpansion&&) = default;
     TestSuiteExpansion& operator=(const TestSuiteExpansion&) = default;
     TestSuiteExpansion& operator=(TestSuiteExpansion&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_suite_label() {
@@ -6099,7 +6102,7 @@
   PatternExpanded(PatternExpanded&&) = default;
   PatternExpanded& operator=(const PatternExpanded&) = default;
   PatternExpanded& operator=(PatternExpanded&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::bes::build_event_stream::PatternExpanded::TestSuiteExpansion >* mutable_test_suite_expansions() {
@@ -6121,7 +6124,7 @@
   TargetConfigured(TargetConfigured&&) = default;
   TargetConfigured& operator=(const TargetConfigured&) = default;
   TargetConfigured& operator=(TargetConfigured&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_target_kind() {
@@ -6162,7 +6165,7 @@
   File(File&&) = default;
   File& operator=(const File&) = default;
   File& operator=(File&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< std::string >* mutable_path_prefix() {
@@ -6213,7 +6216,7 @@
   NamedSetOfFiles(NamedSetOfFiles&&) = default;
   NamedSetOfFiles& operator=(const NamedSetOfFiles&) = default;
   NamedSetOfFiles& operator=(NamedSetOfFiles&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::bes::build_event_stream::File >* mutable_files() {
@@ -6262,7 +6265,7 @@
   ActionExecuted(ActionExecuted&&) = default;
   ActionExecuted& operator=(const ActionExecuted&) = default;
   ActionExecuted& operator=(ActionExecuted&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   bool* mutable_success() {
@@ -6345,7 +6348,7 @@
   OutputGroup(OutputGroup&&) = default;
   OutputGroup& operator=(const OutputGroup&) = default;
   OutputGroup& operator=(OutputGroup&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -6396,7 +6399,7 @@
   TargetComplete(TargetComplete&&) = default;
   TargetComplete& operator=(const TargetComplete&) = default;
   TargetComplete& operator=(TargetComplete&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   bool* mutable_success() {
@@ -6466,7 +6469,7 @@
       TimingBreakdown(TimingBreakdown&&) = default;
       TimingBreakdown& operator=(const TimingBreakdown&) = default;
       TimingBreakdown& operator=(TimingBreakdown&&) = default;
-      void SerializeToOstream(std::ostream* output__) const;
+      void SerializeToOstream(OutputStream* output__) const;
       size_t ByteSizeLong() const;
       void Clear();
       std::vector< ::bes::build_event_stream::TestResult::ExecutionInfo::TimingBreakdown >* mutable_child() {
@@ -6500,7 +6503,7 @@
       ResourceUsage(ResourceUsage&&) = default;
       ResourceUsage& operator=(const ResourceUsage&) = default;
       ResourceUsage& operator=(ResourceUsage&&) = default;
-      void SerializeToOstream(std::ostream* output__) const;
+      void SerializeToOstream(OutputStream* output__) const;
       size_t ByteSizeLong() const;
       void Clear();
       std::string* mutable_name() {
@@ -6534,7 +6537,7 @@
     ExecutionInfo(ExecutionInfo&&) = default;
     ExecutionInfo& operator=(const ExecutionInfo&) = default;
     ExecutionInfo& operator=(ExecutionInfo&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     int32_t* mutable_timeout_seconds() {
@@ -6598,7 +6601,7 @@
   TestResult(TestResult&&) = default;
   TestResult& operator=(const TestResult&) = default;
   TestResult& operator=(TestResult&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::build_event_stream::TestStatus* mutable_status() {
@@ -6659,7 +6662,7 @@
   TestProgress(TestProgress&&) = default;
   TestProgress& operator=(const TestProgress&) = default;
   TestProgress& operator=(TestProgress&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_uri() {
@@ -6703,7 +6706,7 @@
   TestSummary(TestSummary&&) = default;
   TestSummary& operator=(const TestSummary&) = default;
   TestSummary& operator=(TestSummary&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::build_event_stream::TestStatus* mutable_overall_status() {
@@ -6785,7 +6788,7 @@
   TargetSummary(TargetSummary&&) = default;
   TargetSummary& operator=(const TargetSummary&) = default;
   TargetSummary& operator=(TargetSummary&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   bool* mutable_overall_build_success() {
@@ -6811,7 +6814,7 @@
     ExitCode(ExitCode&&) = default;
     ExitCode& operator=(const ExitCode&) = default;
     ExitCode& operator=(ExitCode&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_name() {
@@ -6834,7 +6837,7 @@
     AnomalyReport(AnomalyReport&&) = default;
     AnomalyReport& operator=(const AnomalyReport&) = default;
     AnomalyReport& operator=(AnomalyReport&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     bool* mutable_was_suspended() {
@@ -6861,7 +6864,7 @@
   BuildFinished(BuildFinished&&) = default;
   BuildFinished& operator=(const BuildFinished&) = default;
   BuildFinished& operator=(BuildFinished&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   bool* mutable_overall_success() {
@@ -6914,7 +6917,7 @@
       ActionData(ActionData&&) = default;
       ActionData& operator=(const ActionData&) = default;
       ActionData& operator=(ActionData&&) = default;
-      void SerializeToOstream(std::ostream* output__) const;
+      void SerializeToOstream(OutputStream* output__) const;
       size_t ByteSizeLong() const;
       void Clear();
       std::string* mutable_mnemonic() {
@@ -6964,7 +6967,7 @@
       RunnerCount(RunnerCount&&) = default;
       RunnerCount& operator=(const RunnerCount&) = default;
       RunnerCount& operator=(RunnerCount&&) = default;
-      void SerializeToOstream(std::ostream* output__) const;
+      void SerializeToOstream(OutputStream* output__) const;
       size_t ByteSizeLong() const;
       void Clear();
       std::string* mutable_name() {
@@ -7003,7 +7006,7 @@
     ActionSummary(ActionSummary&&) = default;
     ActionSummary& operator=(const ActionSummary&) = default;
     ActionSummary& operator=(ActionSummary&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     int64_t* mutable_actions_created() {
@@ -7053,7 +7056,7 @@
       GarbageMetrics(GarbageMetrics&&) = default;
       GarbageMetrics& operator=(const GarbageMetrics&) = default;
       GarbageMetrics& operator=(GarbageMetrics&&) = default;
-      void SerializeToOstream(std::ostream* output__) const;
+      void SerializeToOstream(OutputStream* output__) const;
       size_t ByteSizeLong() const;
       void Clear();
       std::string* mutable_type() {
@@ -7081,7 +7084,7 @@
     MemoryMetrics(MemoryMetrics&&) = default;
     MemoryMetrics& operator=(const MemoryMetrics&) = default;
     MemoryMetrics& operator=(MemoryMetrics&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     int64_t* mutable_used_heap_size_post_build() {
@@ -7118,7 +7121,7 @@
     TargetMetrics(TargetMetrics&&) = default;
     TargetMetrics& operator=(const TargetMetrics&) = default;
     TargetMetrics& operator=(TargetMetrics&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     int64_t* mutable_targets_loaded() {
@@ -7148,7 +7151,7 @@
     PackageMetrics(PackageMetrics&&) = default;
     PackageMetrics& operator=(const PackageMetrics&) = default;
     PackageMetrics& operator=(PackageMetrics&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     int64_t* mutable_packages_loaded() {
@@ -7179,7 +7182,7 @@
     TimingMetrics(TimingMetrics&&) = default;
     TimingMetrics& operator=(const TimingMetrics&) = default;
     TimingMetrics& operator=(TimingMetrics&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     int64_t* mutable_cpu_time_in_ms() {
@@ -7219,7 +7222,7 @@
     CumulativeMetrics(CumulativeMetrics&&) = default;
     CumulativeMetrics& operator=(const CumulativeMetrics&) = default;
     CumulativeMetrics& operator=(CumulativeMetrics&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     int32_t* mutable_num_analyses() {
@@ -7245,7 +7248,7 @@
       FilesMetric(FilesMetric&&) = default;
       FilesMetric& operator=(const FilesMetric&) = default;
       FilesMetric& operator=(FilesMetric&&) = default;
-      void SerializeToOstream(std::ostream* output__) const;
+      void SerializeToOstream(OutputStream* output__) const;
       size_t ByteSizeLong() const;
       void Clear();
       int64_t* mutable_size_in_bytes() {
@@ -7273,7 +7276,7 @@
     ArtifactMetrics(ArtifactMetrics&&) = default;
     ArtifactMetrics& operator=(const ArtifactMetrics&) = default;
     ArtifactMetrics& operator=(ArtifactMetrics&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     ::bes::build_event_stream::BuildMetrics::ArtifactMetrics::FilesMetric* mutable_source_artifacts_read() {
@@ -7304,7 +7307,7 @@
     EvaluationStat(EvaluationStat&&) = default;
     EvaluationStat& operator=(const EvaluationStat&) = default;
     EvaluationStat& operator=(EvaluationStat&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_skyfunction_name() {
@@ -7334,7 +7337,7 @@
       RuleClassCount(RuleClassCount&&) = default;
       RuleClassCount& operator=(const RuleClassCount&) = default;
       RuleClassCount& operator=(RuleClassCount&&) = default;
-      void SerializeToOstream(std::ostream* output__) const;
+      void SerializeToOstream(OutputStream* output__) const;
       size_t ByteSizeLong() const;
       void Clear();
       std::string* mutable_key() {
@@ -7373,7 +7376,7 @@
       AspectCount(AspectCount&&) = default;
       AspectCount& operator=(const AspectCount&) = default;
       AspectCount& operator=(AspectCount&&) = default;
-      void SerializeToOstream(std::ostream* output__) const;
+      void SerializeToOstream(OutputStream* output__) const;
       size_t ByteSizeLong() const;
       void Clear();
       std::string* mutable_key() {
@@ -7435,7 +7438,7 @@
     BuildGraphMetrics(BuildGraphMetrics&&) = default;
     BuildGraphMetrics& operator=(const BuildGraphMetrics&) = default;
     BuildGraphMetrics& operator=(BuildGraphMetrics&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     int32_t* mutable_action_lookup_value_count() {
@@ -7545,7 +7548,7 @@
       WorkerStats(WorkerStats&&) = default;
       WorkerStats& operator=(const WorkerStats&) = default;
       WorkerStats& operator=(WorkerStats&&) = default;
-      void SerializeToOstream(std::ostream* output__) const;
+      void SerializeToOstream(OutputStream* output__) const;
       size_t ByteSizeLong() const;
       void Clear();
       int64_t* mutable_collect_time_in_ms() {
@@ -7601,7 +7604,7 @@
     WorkerMetrics(WorkerMetrics&&) = default;
     WorkerMetrics& operator=(const WorkerMetrics&) = default;
     WorkerMetrics& operator=(WorkerMetrics&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     int32_t* mutable_worker_id() {
@@ -7695,7 +7698,7 @@
       SystemNetworkStats(SystemNetworkStats&&) = default;
       SystemNetworkStats& operator=(const SystemNetworkStats&) = default;
       SystemNetworkStats& operator=(SystemNetworkStats&&) = default;
-      void SerializeToOstream(std::ostream* output__) const;
+      void SerializeToOstream(OutputStream* output__) const;
       size_t ByteSizeLong() const;
       void Clear();
       uint64_t* mutable_bytes_sent() {
@@ -7747,7 +7750,7 @@
     NetworkMetrics(NetworkMetrics&&) = default;
     NetworkMetrics& operator=(const NetworkMetrics&) = default;
     NetworkMetrics& operator=(NetworkMetrics&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     ::bes::build_event_stream::BuildMetrics::NetworkMetrics::SystemNetworkStats* mutable_system_network_stats() {
@@ -7783,7 +7786,7 @@
       WorkerPoolStats(WorkerPoolStats&&) = default;
       WorkerPoolStats& operator=(const WorkerPoolStats&) = default;
       WorkerPoolStats& operator=(WorkerPoolStats&&) = default;
-      void SerializeToOstream(std::ostream* output__) const;
+      void SerializeToOstream(OutputStream* output__) const;
       size_t ByteSizeLong() const;
       void Clear();
       int32_t* mutable_hash() {
@@ -7845,7 +7848,7 @@
     WorkerPoolMetrics(WorkerPoolMetrics&&) = default;
     WorkerPoolMetrics& operator=(const WorkerPoolMetrics&) = default;
     WorkerPoolMetrics& operator=(WorkerPoolMetrics&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::vector< ::bes::build_event_stream::BuildMetrics::WorkerPoolMetrics::WorkerPoolStats >* mutable_worker_pool_stats() {
@@ -7872,7 +7875,7 @@
       RaceStatistics(RaceStatistics&&) = default;
       RaceStatistics& operator=(const RaceStatistics&) = default;
       RaceStatistics& operator=(RaceStatistics&&) = default;
-      void SerializeToOstream(std::ostream* output__) const;
+      void SerializeToOstream(OutputStream* output__) const;
       size_t ByteSizeLong() const;
       void Clear();
       std::string* mutable_mnemonic() {
@@ -7909,7 +7912,7 @@
     DynamicExecutionMetrics(DynamicExecutionMetrics&&) = default;
     DynamicExecutionMetrics& operator=(const DynamicExecutionMetrics&) = default;
     DynamicExecutionMetrics& operator=(DynamicExecutionMetrics&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::vector< ::bes::build_event_stream::BuildMetrics::DynamicExecutionMetrics::RaceStatistics >* mutable_race_statistics() {
@@ -7948,7 +7951,7 @@
   BuildMetrics(BuildMetrics&&) = default;
   BuildMetrics& operator=(const BuildMetrics&) = default;
   BuildMetrics& operator=(BuildMetrics&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::build_event_stream::BuildMetrics::ActionSummary* mutable_action_summary() {
@@ -8010,7 +8013,7 @@
   BuildToolLogs(BuildToolLogs&&) = default;
   BuildToolLogs& operator=(const BuildToolLogs&) = default;
   BuildToolLogs& operator=(BuildToolLogs&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::bes::build_event_stream::File >* mutable_log() {
@@ -8028,7 +8031,7 @@
   ConvenienceSymlinksIdentified(ConvenienceSymlinksIdentified&&) = default;
   ConvenienceSymlinksIdentified& operator=(const ConvenienceSymlinksIdentified&) = default;
   ConvenienceSymlinksIdentified& operator=(ConvenienceSymlinksIdentified&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::bes::build_event_stream::ConvenienceSymlink >* mutable_convenience_symlinks() {
@@ -8056,7 +8059,7 @@
   ConvenienceSymlink(ConvenienceSymlink&&) = default;
   ConvenienceSymlink& operator=(const ConvenienceSymlink&) = default;
   ConvenienceSymlink& operator=(ConvenienceSymlink&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_path() {
@@ -8092,7 +8095,7 @@
   ExecRequestConstructed(ExecRequestConstructed&&) = default;
   ExecRequestConstructed& operator=(const ExecRequestConstructed&) = default;
   ExecRequestConstructed& operator=(ExecRequestConstructed&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_working_directory() {
@@ -8134,7 +8137,7 @@
   EnvironmentVariable(EnvironmentVariable&&) = default;
   EnvironmentVariable& operator=(const EnvironmentVariable&) = default;
   EnvironmentVariable& operator=(EnvironmentVariable&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -8211,7 +8214,7 @@
   BuildEvent(BuildEvent&&) = default;
   BuildEvent& operator=(const BuildEvent&) = default;
   BuildEvent& operator=(BuildEvent&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::bes::build_event_stream::BuildEventId* mutable_id() {
diff --git a/src/build_event_streamer.cc b/src/build_event_streamer.cc
index 23f4a59..677a6c1 100644
--- a/src/build_event_streamer.cc
+++ b/src/build_event_streamer.cc
@@ -15,10 +15,9 @@
 #include "build_event_streamer.h"
 
 #include <cstdarg>
-#include <ostream>
-#include <numeric>
 
 #include "metrics.h"
+#include "output_stream.h"
 #include "persistent_mode.h"
 #include "util.h"
 #include "version.h"
@@ -42,14 +41,10 @@
                                        const BuildMetadataMap& metadata,
                                        const std::string& build_id,
                                        int64_t start_time_millis,
-                                       std::ostream* out) :
-  ninja_command_(ninja_command),
-  config_string_(config_string),
-  metadata_(metadata),
-  build_id_(build_id),
-  start_time_millis_(start_time_millis),
-  out_(out) {
-}
+                                       OutputStream* out)
+    : ninja_command_(ninja_command), config_string_(config_string),
+      metadata_(metadata), build_id_(build_id),
+      start_time_millis_(start_time_millis), out_(out) {}
 
 BuildEventStreamer::~BuildEventStreamer() = default;
 
diff --git a/src/build_event_streamer.h b/src/build_event_streamer.h
index 306c78c..8b48ecf 100644
--- a/src/build_event_streamer.h
+++ b/src/build_event_streamer.h
@@ -15,13 +15,13 @@
 #ifndef NINJA_BUILD_EVENT_STREAMER_H_
 #define NINJA_BUILD_EVENT_STREAMER_H_
 
-#include "status.h"
-
-#include <iosfwd>
 #include <map>
 #include <string>
 
 #include "bes_types.h"
+#include "status.h"
+
+struct OutputStream;
 
 /// Writes Build Event Protocol messages in response
 /// to build events.
@@ -36,9 +36,8 @@
   BuildEventStreamer(const char* ninja_command,
                      const std::string& config_string,
                      const BuildMetadataMap& metadata,
-                     const std::string& build_id,
-                     int64_t start_time_millis,
-                     std::ostream* out);
+                     const std::string& build_id, int64_t start_time_millis,
+                     OutputStream* out);
   virtual ~BuildEventStreamer();
 
   void EdgeAddedToPlan(const Edge* edge) override;
@@ -75,7 +74,7 @@
 
   // Output stream (should be configured un-buffered)
   // Not owned, so the stream object should outlive this object.
-  std::ostream* out_;
+  OutputStream* out_ = nullptr;
 };
 
 #endif // NINJA_BUILD_EVENT_STREAMER_H_
diff --git a/src/build_event_streamer_test.cc b/src/build_event_streamer_test.cc
index 5db9985..051626e 100644
--- a/src/build_event_streamer_test.cc
+++ b/src/build_event_streamer_test.cc
@@ -14,8 +14,7 @@
 
 #include "build_event_streamer.h"
 
-#include <sstream>
-
+#include "output_stream.h"
 #include "test.h"
 
 static const BuildMetadataMap empty_metadata;
@@ -36,7 +35,7 @@
 }
 
 TEST(BuildEventStreamer, BasicStartAndFinish) {
-  std::ostringstream out;
+  StringOutputStream out;
   BuildEventStreamer streamer("your typed command", "config text",
                               empty_metadata,
                               "build-id:1726dfe8a00c",
diff --git a/src/ninja.cc b/src/ninja.cc
index e4f3ad1..5fcb5bb 100644
--- a/src/ninja.cc
+++ b/src/ninja.cc
@@ -21,7 +21,6 @@
 
 #include <algorithm>
 #include <cstdlib>
-#include <fstream>
 #include <memory>
 
 #ifdef _WIN32
@@ -36,7 +35,6 @@
 #include <unistd.h>
 #endif
 
-#include "async_loop.h"
 #include "browse.h"
 #include "build.h"
 #include "build_config.h"
@@ -44,7 +42,6 @@
 #include "build_log.h"
 #include "clean.h"
 #include "debug_flags.h"
-#include "depfile_parser.h"
 #include "deps_log.h"
 #include "disk_interface.h"
 #include "graph.h"
@@ -325,17 +322,30 @@
       "\n"
       "  --jobserver   enable GNU jobserver pool\n"
       "\n"
-      "build event streaming options:\n"
-      "  --bes_output FILE           build event stream output (binary "
-      "protobuf)\n"
-      "                              This option enables build event "
-      "streaming.\n"
-      "  --resultstore_output FILE            ResultStore stream output (binary proto)\n"
-      "                              This enables ResultStore streaming.\n"
-      "  --bes_metadata KEY=VALUE    user-defined metadata about the build\n"
-      "                              (repeatable, cumulative)\n"
-      "  --chrome_trace FILE         Chrome trace output (JSON array)\n",
-      kNinjaVersion, config.parallelism);
+      "Build event streaming options:\n\n"
+
+      "  These options generate files describing build events in various "
+      "formats.\n"
+      "  File paths are relative to the Ninja build directory.\n"
+      "  Use a .gz suffix to directly generate a gzip-compressed output "
+      "file.\n\n"
+
+      "  --bes_output FILE           Generate build_event_stream.proto binary "
+      "output.\n\n"
+
+      "  --resultstore_output FILE   Generate resultstore_upload.proto binary "
+      "output\n\n"
+
+      "  --bes_metadata KEY=VALUE    user-defined metadata about the build "
+      "that will be\n"
+      "                              embedded into --bes_output and "
+      "--resultstore_output\n"
+      "                              outputs (repeatable, cumulative)\n\n"
+
+      "  --chrome_trace FILE         Generate Chrome trace output (JSON "
+      "array).\n\n",
+      kNinjaVersion,
+      config.parallelism);
 }
 
 /// Choose a default value for the -j (parallelism) flag.
@@ -1699,7 +1709,7 @@
 
   ManifestParser parser(&state_, &path_recording_disk_interface_, parser_opts);
   std::string err;
-  if (!parser.Load(config_->input_file.c_str(), &err)) {
+  if (!parser.Load(config_->input_file, &err)) {
     status_->Error("%s", err.c_str());
     return 1;
   }
@@ -1716,22 +1726,68 @@
   return kBuildCanProceed;
 }
 
-static std::unique_ptr<std::ofstream> MakeUnbufferedOutputStream(
-    const std::string& name) {
-  std::unique_ptr<std::ofstream> out;
-  if (!name.empty()) {
-    out = std::make_unique<std::ofstream>(name, std::ios::binary);
-    std::filebuf* buf = out->rdbuf();  // internal stream buffer
-    buf->pubsetbuf(nullptr, 0);        // disable buffering
-  }
-  return out;
-}
+// Convenience OutputStream derived class that writes to a FILE*
+// handle, possibly using gzip compression. Takes ownership of file.
+// Usage is:
+//  1) Create instance.
+//  2) Call Init() method, which can report an error.
+//  3) Use the instance as an OutputStream through Write() and Flush() calls.
+//  4) Destroy instance to flush everything to the file and close it.
+struct FileOrGzipOutputStream : public OutputStream {
+  FileOrGzipOutputStream() = default;
 
+  ~FileOrGzipOutputStream() {
+    gzip_output_.reset();
+    file_output_.reset();
+    fclose(file_);
+  }
+
+  bool Init(const char* file_path, std::string* error) {
+    assert(file_path != nullptr && "Invalid null file path");
+    assert(file_ == nullptr && "Cannot call Init() method twice!");
+    file_ = ::fopen(file_path, "wt");
+    if (!file_) {
+      *error =
+          StringFormat("Cannot create file %s: %s", file_path, strerror(errno));
+      return false;
+    }
+
+    auto endsWith = [](StringPiece str, StringPiece needle) {
+      return str.len_ >= needle.len_ &&
+             !memcmp(str.str_ + str.len_ - needle.len_, needle.str_,
+                     needle.len_);
+      return false;
+    };
+    file_output_.reset(new StdioOutputStream(file_));
+    output_ = file_output_.get();
+    if (endsWith(file_path, ".gz")) {
+      if (!GzipOutputStream::IsSupported()) {
+        *error = "This version of Ninja cannot write gzip files!";
+        return false;
+      }
+      gzip_output_.reset(new GzipOutputStream(*file_output_));
+      output_ = gzip_output_.get();
+    }
+    return true;
+  }
+
+  void Write(const char* str, size_t len) override { output_->Write(str, len); }
+
+  void Flush() override { output_->Flush(); }
+
+  FILE* file_ = nullptr;
+  std::string error_;
+  std::unique_ptr<StdioOutputStream> file_output_;
+  std::unique_ptr<GzipOutputStream> gzip_output_;
+  OutputStream* output_ = nullptr;
+};
 
 // Convenience class used to manage the build event streaming support.
 // Usage is simply:
 //
-//  - Create instance, if --bes-output is used, this will modify
+//  - Create instance.
+//
+//  - Call Init() method.  If --bes-output is used, this will modify
 //    the state of the NinjaMain instance to active the feature
 //    by opening an output file stream and connecting it to
 //    BuildEventStreamer instance that will receive build status
@@ -1743,13 +1799,17 @@
 //
 class BuildEventStreamState {
  public:
-  explicit BuildEventStreamState(NinjaMain& ninja) : ninja_(ninja) {
+  explicit BuildEventStreamState(NinjaMain& ninja) : ninja_(ninja) {}
+
+  bool Init(std::string* error) {
     const BuildConfig& config = *(ninja_.config_);
     if (config.bes_output.empty())
-      return;
+      return true;
 
     const char* build_id = getenv("NINJA_BUILD_ID");
-    out_stream_ = MakeUnbufferedOutputStream(config.bes_output);
+    out_stream_.reset(new FileOrGzipOutputStream());
+    if (!out_stream_->Init(config.bes_output.c_str(), error))
+      return false;
 
     auto bes = std::make_unique<BuildEventStreamer>(
         // TODO: pass full command, not just the tool path
@@ -1760,6 +1820,7 @@
     // Add the streamer to the status listener group.
     bes_status_ptr_ = bes.get();
     ninja_.status_->AddListener(std::move(bes));
+    return true;
   }
 
   ~BuildEventStreamState() {
@@ -1770,7 +1831,7 @@
  private:
   NinjaMain& ninja_;
 
-  std::unique_ptr<std::ofstream> out_stream_;
+  std::unique_ptr<FileOrGzipOutputStream> out_stream_;
 
   // Non-owning pointer to BuildEventStreamer instance.
   Status* bes_status_ptr_ = nullptr;
@@ -1791,13 +1852,18 @@
 //
 class ResultStoreStreamState {
  public:
-  explicit ResultStoreStreamState(NinjaMain& ninja) : ninja_(ninja) {
+  explicit ResultStoreStreamState(NinjaMain& ninja) : ninja_(ninja) {}
+
+  bool Init(std::string* error) {
     const BuildConfig& config = *(ninja_.config_);
     if (config.resultstore_output.empty())
-      return;
+      return true;
+
+    out_stream_.reset(new FileOrGzipOutputStream());
+    if (!out_stream_->Init(config.resultstore_output.c_str(), error))
+      return false;
 
     const char* build_id = getenv("NINJA_BUILD_ID");
-    out_stream_ = MakeUnbufferedOutputStream(config.resultstore_output);
 
     auto rs = std::make_unique<ResultStoreStreamer>(
         ninja_.original_ninja_command_,
@@ -1810,6 +1876,7 @@
     // Add the streamer to the status listener group.
     rs_status_ptr_ = rs.get();
     ninja_.status_->AddListener(std::move(rs));
+    return true;
   }
 
   ~ResultStoreStreamState() {
@@ -1820,63 +1887,35 @@
  private:
   NinjaMain& ninja_;
 
-  std::unique_ptr<std::ofstream> out_stream_;
+  std::unique_ptr<FileOrGzipOutputStream> out_stream_;
 
   // Non-owning pointer to ResultStoreStreamer instance.
   Status* rs_status_ptr_ = nullptr;
 };
 
-/// Convenience OutputStream derived class that writes to a FILE*
-/// handle, possibly using gzip compression. Takes ownership of file.
-struct FileOrGzipOutputStream : public OutputStream {
-  FileOrGzipOutputStream(FILE* file, bool use_gzip)
-      : file_(file), file_output_(new StdioOutputStream(file_)),
-        output_(file_output_.get()) {
-    if (use_gzip) {
-      if (!GzipOutputStream::IsSupported())
-        Fatal("This version of Ninja cannot write gzip files!");
-      gzip_output_.reset(new GzipOutputStream(*file_output_));
-      output_ = gzip_output_.get();
-    }
-  }
-
-  ~FileOrGzipOutputStream() {
-    gzip_output_.reset();
-    file_output_.reset();
-    fclose(file_);
-  }
-
-  void Write(const char* str, size_t len) override { output_->Write(str, len); }
-
-  void Flush() override { output_->Flush(); }
-
-  FILE* file_ = nullptr;
-  std::unique_ptr<StdioOutputStream> file_output_;
-  std::unique_ptr<GzipOutputStream> gzip_output_;
-  OutputStream* output_ = nullptr;
-};
-
+// Class holding state used to write a Chrome event trace to a file,
+// possibly using gzip compression to save 20x disk size. Usage:
+//  1) Create instance.
+//  2) Call Init(), which can report error. This registers a Status listener.
+//  3) Run the build as usual.
+//  4) Close the instance, which will flush everything to the final file.
 class ChromeTracingState {
  public:
-  ChromeTracingState(NinjaMain& ninja) : ninja_(ninja) {
+  ChromeTracingState(NinjaMain& ninja) : ninja_(ninja) {}
+
+  // Initialize new instance. File path is taken from
+  // config_.chrome_trace_output.
+  bool Init(std::string* error) {
     const BuildConfig& config = *(ninja_.config_);
     if (config.chrome_trace_output.empty())
-      return;
+      return true;
 
     file_path_ = config.chrome_trace_output.c_str();
-    FILE* file = fopen(file_path_, "wt");
-    if (!file)
-      Fatal("Cannot write to file %s: %s", file_path_, strerror(errno));
 
-    auto endsWith = [](StringPiece str, StringPiece needle) {
-      return str.len_ >= needle.len_ &&
-             !memcmp(str.str_ + str.len_ - needle.len_, needle.str_,
-                     needle.len_);
+    output_.reset(new FileOrGzipOutputStream());
+    if (!output_->Init(file_path_, error))
       return false;
-    };
-    bool use_gzip = endsWith(file_path_, ".gz");
 
-    output_.reset(new FileOrGzipOutputStream(file, use_gzip));
     *output_ << "[\n";
 
     auto trace_output = [this](ChromeTraceEvent&& event) {
@@ -1895,6 +1934,7 @@
     auto chrome_trace = NewChromeTracingStatus(std::move(trace_output));
     chrome_trace_ptr_ = chrome_trace.get();
     ninja_.status_->AddListener(std::move(chrome_trace));
+    return true;
   }
 
   ~ChromeTracingState() {
@@ -1924,15 +1964,29 @@
 ExitStatus NinjaMain::RunBuild(int argc, char** argv) {
   // Enable build event or ResultStore stream support if needed. This may
   // modify the state of *self so must be performed first.
-  const BuildEventStreamState build_event_stream_state(*this);
-  const ResultStoreStreamState resultstore_stream_state(*this);
+  std::string err;
+
+  BuildEventStreamState build_event_stream_state(*this);
+  if (!build_event_stream_state.Init(&err)) {
+    status_->Error("%s", err.c_str());
+    return ExitFailure;
+  }
+
+  ResultStoreStreamState resultstore_stream_state(*this);
+  if (!resultstore_stream_state.Init(&err)) {
+    status_->Error("%s", err.c_str());
+    return ExitFailure;
+  }
 
   // Do the same for writing build events to a Chrome trace.
   ChromeTracingState chrome_tracing_state(*this);
+  if (!chrome_tracing_state.Init(&err)) {
+    status_->Error("%s", err.c_str());
+    return ExitFailure;
+  }
 
   ParsePreviousElapsedTimes();
 
-  std::string err;
   disk_interface_.AllowStatCache(g_experimental_statcache);
 
   Builder builder(&state_, *config_, &build_log_, &deps_log_, &disk_interface_,
diff --git a/src/proto.cc b/src/proto.cc
index c29e621..321bca5 100644
--- a/src/proto.cc
+++ b/src/proto.cc
@@ -14,11 +14,13 @@
 
 #define __STDC_LIMIT_MACROS
 
+#include "proto.h"
+
 #include <inttypes.h>
 #include <stdint.h>
 #include <string.h>
 
-#include "proto.h"
+#include "output_stream.h"
 
 // This file and proto.h implement a minimal write-only protobuf runtime to be
 // used with headers generated by misc/generate_proto_header.py.
@@ -81,6 +83,23 @@
   output->write(reinterpret_cast<char*>(buf), target - buf);
 }
 
+static void WriteVarint32WithType(OutputStream* output, int number,
+                                  uint32_t value, WireType type) {
+  uint8_t buf[StaticVarintSize<UINT32_MAX>::value + 1];
+  uint8_t* target = buf;
+
+  *target++ = MakeTag(number, type);
+
+  while (value >= 0x80) {
+    *target = static_cast<uint8_t>(value | 0x80);
+    value >>= 7;
+    ++target;
+  }
+  *target++ = static_cast<uint8_t>(value);
+
+  output->Write(reinterpret_cast<char*>(buf), target - buf);
+}
+
 void WriteVarint32NoTag(std::ostream* output, uint32_t value) {
   uint8_t buf[StaticVarintSize<UINT32_MAX>::value];
   uint8_t *target = buf;
@@ -152,3 +171,75 @@
 void WriteLengthDelimited(std::ostream* output, int number, size_t size) {
   WriteVarint32WithType(output, number, size, WIRETYPE_LENGTH_DELIMITED);
 }
+
+void WriteVarint32NoTag(OutputStream* output, uint32_t value) {
+  uint8_t buf[StaticVarintSize<UINT32_MAX>::value];
+  uint8_t* target = buf;
+
+  while (value >= 0x80) {
+    *target = static_cast<uint8_t>(value | 0x80);
+    value >>= 7;
+    ++target;
+  }
+  *target++ = static_cast<uint8_t>(value);
+
+  output->Write(reinterpret_cast<char*>(buf), target - buf);
+}
+
+void WriteVarint32(OutputStream* output, int number, uint32_t value) {
+  WriteVarint32WithType(output, number, value, WIRETYPE_VARINT);
+}
+
+void WriteVarint32SignExtended(OutputStream* output, int number,
+                               int32_t value) {
+  if (value < 0) {
+    WriteVarint64(output, number, static_cast<uint64_t>(value));
+  } else {
+    WriteVarint32(output, number, static_cast<uint32_t>(value));
+  }
+}
+
+void WriteVarint64(OutputStream* output, int number, uint64_t value) {
+  uint8_t buf[StaticVarintSize<UINT64_MAX>::value + 1];
+  uint8_t* target = buf;
+
+  *target++ = MakeTag(number, WIRETYPE_VARINT);
+
+  while (value >= 0x80) {
+    *target = static_cast<uint8_t>(value | 0x80);
+    value >>= 7;
+    ++target;
+  }
+  *target++ = static_cast<uint8_t>(value);
+
+  output->Write(reinterpret_cast<char*>(buf), target - buf);
+}
+
+void WriteFixed32(OutputStream* output, int number, uint32_t value) {
+  uint8_t buf[sizeof(value) + 1];
+  uint8_t* target = buf;
+
+  *target++ = MakeTag(number, WIRETYPE_FIXED32);
+  memcpy(target, &value, sizeof(value));
+
+  output->Write(reinterpret_cast<char*>(buf), sizeof(buf));
+}
+
+void WriteFixed64(OutputStream* output, int number, uint64_t value) {
+  uint8_t buf[sizeof(value) + 1];
+  uint8_t* target = buf;
+
+  *target++ = MakeTag(number, WIRETYPE_FIXED64);
+  memcpy(target, &value, sizeof(value));
+
+  output->Write(reinterpret_cast<char*>(buf), sizeof(buf));
+}
+
+void WriteString(OutputStream* output, int number, const std::string& value) {
+  WriteLengthDelimited(output, number, value.size());
+  output->Write(value.data(), value.size());
+}
+
+void WriteLengthDelimited(OutputStream* output, int number, size_t size) {
+  WriteVarint32WithType(output, number, size, WIRETYPE_LENGTH_DELIMITED);
+}
diff --git a/src/proto.h b/src/proto.h
index 8552719..190bb5f 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -15,7 +15,9 @@
 #ifndef NINJA_PROTO_H_
 #define NINJA_PROTO_H_
 
+#include <cstdint>
 #include <iostream>
+struct OutputStream;
 
 // This file and proto.cc implement a minimal write-only protobuf runtime to be
 // used with headers generated by misc/generate_proto_header.py.
@@ -98,6 +100,7 @@
   return VarintSize32(value.size()) + value.size();
 }
 
+// std::ostream support (deprecated)
 void WriteVarint32(std::ostream* output, int number, uint32_t value);
 void WriteVarint32NoTag(std::ostream* output, uint32_t value);
 void WriteVarint32SignExtended(std::ostream* output, int number, int32_t value);
@@ -107,4 +110,14 @@
 void WriteString(std::ostream* output, int number, const std::string& value);
 void WriteLengthDelimited(std::ostream* output, int number, size_t size);
 
+// OutputStream support
+void WriteVarint32(OutputStream* output, int number, uint32_t value);
+void WriteVarint32NoTag(OutputStream* output, uint32_t value);
+void WriteVarint32SignExtended(OutputStream* output, int number, int32_t value);
+void WriteVarint64(OutputStream* output, int number, uint64_t value);
+void WriteFixed32(OutputStream* output, int number, uint32_t value);
+void WriteFixed64(OutputStream* output, int number, uint64_t value);
+void WriteString(OutputStream* output, int number, const std::string& value);
+void WriteLengthDelimited(OutputStream* output, int number, size_t size);
+
 #endif
diff --git a/src/resultstore.pb.cc b/src/resultstore.pb.cc
index 9348bf2..feb281e 100644
--- a/src/resultstore.pb.cc
+++ b/src/resultstore.pb.cc
@@ -1,9 +1,10 @@
 // This file is auto-generated by generate_proto_header.py, do not edit
 
+// clang-format off
+
 #include "resultstore.pb.h"
 
-#include <iostream>
-
+#include "output_stream.h"
 #include "proto.h"
 
 namespace rs {
@@ -15,7 +16,7 @@
   fully_decode_reserved_expansion_ = static_cast< bool >(0);
 }
 
-void Http::SerializeToOstream(std::ostream* output__) const {
+void Http::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : rules_) {
     if (has_rules_) {
       WriteLengthDelimited(output__, 1,
@@ -60,7 +61,7 @@
   has_path_ = false;
 }
 
-void CustomHttpPattern::SerializeToOstream(std::ostream* output__) const {
+void CustomHttpPattern::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, kind_);
   WriteString(output__, 2, path_);
 }
@@ -100,7 +101,7 @@
   has_additional_bindings_ = false;
 }
 
-void HttpRule::SerializeToOstream(std::ostream* output__) const {
+void HttpRule::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, selector_);
   WriteString(output__, 2, get_);
   WriteString(output__, 3, put_);
@@ -217,7 +218,7 @@
   has_file_ = false;
 }
 
-void FileDescriptorSet::SerializeToOstream(std::ostream* output__) const {
+void FileDescriptorSet::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : file_) {
     if (has_file_) {
       WriteLengthDelimited(output__, 1,
@@ -264,7 +265,7 @@
   json_format_ = static_cast< ::rs::google::protobuf::FeatureSet::JsonFormat >(0);
 }
 
-void FeatureSet::SerializeToOstream(std::ostream* output__) const {
+void FeatureSet::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(field_presence_));
   WriteVarint32SignExtended(output__, 2, static_cast<int32_t>(enum_type_));
   WriteVarint32SignExtended(output__, 3, static_cast<int32_t>(repeated_field_encoding_));
@@ -356,7 +357,7 @@
   has_uninterpreted_option_ = false;
 }
 
-void FileOptions::SerializeToOstream(std::ostream* output__) const {
+void FileOptions::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, java_package_);
   WriteString(output__, 8, java_outer_classname_);
   WriteVarint32(output__, 10, java_multiple_files_);
@@ -561,7 +562,7 @@
   has_leading_detached_comments_ = false;
 }
 
-void SourceCodeInfo::Location::SerializeToOstream(std::ostream* output__) const {
+void SourceCodeInfo::Location::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : path_) {
     WriteVarint32SignExtended(output__, 1, elem);
   }
@@ -640,7 +641,7 @@
   has_location_ = false;
 }
 
-void SourceCodeInfo::SerializeToOstream(std::ostream* output__) const {
+void SourceCodeInfo::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : location_) {
     if (has_location_) {
       WriteLengthDelimited(output__, 1,
@@ -689,7 +690,7 @@
   edition_ = static_cast< ::rs::google::protobuf::Edition >(0);
 }
 
-void FileDescriptorProto::SerializeToOstream(std::ostream* output__) const {
+void FileDescriptorProto::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   WriteString(output__, 2, package_);
   for (const auto& elem : dependency_) {
@@ -901,7 +902,7 @@
   repeated_ = static_cast< bool >(0);
 }
 
-void ExtensionRangeOptions::Declaration::SerializeToOstream(std::ostream* output__) const {
+void ExtensionRangeOptions::Declaration::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, number_);
   WriteString(output__, 2, full_name_);
   WriteString(output__, 3, type_);
@@ -960,7 +961,7 @@
   verification_ = static_cast< ::rs::google::protobuf::ExtensionRangeOptions::VerificationState >(0);
 }
 
-void ExtensionRangeOptions::SerializeToOstream(std::ostream* output__) const {
+void ExtensionRangeOptions::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : uninterpreted_option_) {
     if (has_uninterpreted_option_) {
       WriteLengthDelimited(output__, 999,
@@ -1049,7 +1050,7 @@
   has_uninterpreted_option_ = false;
 }
 
-void MessageOptions::SerializeToOstream(std::ostream* output__) const {
+void MessageOptions::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32(output__, 1, message_set_wire_format_);
   WriteVarint32(output__, 2, no_standard_descriptor_accessor_);
   WriteVarint32(output__, 3, deprecated_);
@@ -1142,7 +1143,7 @@
   has_options_ = false;
 }
 
-void DescriptorProto::ExtensionRange::SerializeToOstream(std::ostream* output__) const {
+void DescriptorProto::ExtensionRange::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, start_);
   WriteVarint32SignExtended(output__, 2, end_);
   if (has_options_) {
@@ -1189,7 +1190,7 @@
   end_ = static_cast< int32_t >(0);
 }
 
-void DescriptorProto::ReservedRange::SerializeToOstream(std::ostream* output__) const {
+void DescriptorProto::ReservedRange::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, start_);
   WriteVarint32SignExtended(output__, 2, end_);
 }
@@ -1229,7 +1230,7 @@
   has_reserved_name_ = false;
 }
 
-void DescriptorProto::SerializeToOstream(std::ostream* output__) const {
+void DescriptorProto::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   for (const auto& elem : field_) {
     if (has_field_) {
@@ -1430,7 +1431,7 @@
   has_value_ = false;
 }
 
-void FieldOptions::EditionDefault::SerializeToOstream(std::ostream* output__) const {
+void FieldOptions::EditionDefault::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 3, static_cast<int32_t>(edition_));
   WriteString(output__, 2, value_);
 }
@@ -1467,7 +1468,7 @@
   edition_removed_ = static_cast< ::rs::google::protobuf::Edition >(0);
 }
 
-void FieldOptions::FeatureSupport::SerializeToOstream(std::ostream* output__) const {
+void FieldOptions::FeatureSupport::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(edition_introduced_));
   WriteVarint32SignExtended(output__, 2, static_cast<int32_t>(edition_deprecated_));
   WriteString(output__, 3, deprecation_warning_);
@@ -1536,7 +1537,7 @@
   has_uninterpreted_option_ = false;
 }
 
-void FieldOptions::SerializeToOstream(std::ostream* output__) const {
+void FieldOptions::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(ctype_));
   WriteVarint32(output__, 2, packed_);
   WriteVarint32SignExtended(output__, 6, static_cast<int32_t>(jstype_));
@@ -1722,7 +1723,7 @@
   proto3_optional_ = static_cast< bool >(0);
 }
 
-void FieldDescriptorProto::SerializeToOstream(std::ostream* output__) const {
+void FieldDescriptorProto::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   WriteVarint32SignExtended(output__, 3, number_);
   WriteVarint32SignExtended(output__, 4, static_cast<int32_t>(label_));
@@ -1831,7 +1832,7 @@
   has_uninterpreted_option_ = false;
 }
 
-void OneofOptions::SerializeToOstream(std::ostream* output__) const {
+void OneofOptions::SerializeToOstream(OutputStream* output__) const {
   if (has_features_) {
     WriteLengthDelimited(output__, 1,
                          features_.ByteSizeLong());
@@ -1881,7 +1882,7 @@
   has_options_ = false;
 }
 
-void OneofDescriptorProto::SerializeToOstream(std::ostream* output__) const {
+void OneofDescriptorProto::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   if (has_options_) {
     WriteLengthDelimited(output__, 2,
@@ -1924,7 +1925,7 @@
   has_uninterpreted_option_ = false;
 }
 
-void EnumOptions::SerializeToOstream(std::ostream* output__) const {
+void EnumOptions::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32(output__, 2, allow_alias_);
   WriteVarint32(output__, 3, deprecated_);
   WriteVarint32(output__, 6, deprecated_legacy_json_field_conflicts_);
@@ -2000,7 +2001,7 @@
   end_ = static_cast< int32_t >(0);
 }
 
-void EnumDescriptorProto::EnumReservedRange::SerializeToOstream(std::ostream* output__) const {
+void EnumDescriptorProto::EnumReservedRange::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, start_);
   WriteVarint32SignExtended(output__, 2, end_);
 }
@@ -2035,7 +2036,7 @@
   has_reserved_name_ = false;
 }
 
-void EnumDescriptorProto::SerializeToOstream(std::ostream* output__) const {
+void EnumDescriptorProto::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   for (const auto& elem : value_) {
     if (has_value_) {
@@ -2135,7 +2136,7 @@
   has_uninterpreted_option_ = false;
 }
 
-void EnumValueOptions::SerializeToOstream(std::ostream* output__) const {
+void EnumValueOptions::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32(output__, 1, deprecated_);
   if (has_features_) {
     WriteLengthDelimited(output__, 2,
@@ -2216,7 +2217,7 @@
   has_options_ = false;
 }
 
-void EnumValueDescriptorProto::SerializeToOstream(std::ostream* output__) const {
+void EnumValueDescriptorProto::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   WriteVarint32SignExtended(output__, 2, number_);
   if (has_options_) {
@@ -2263,7 +2264,7 @@
   has_uninterpreted_option_ = false;
 }
 
-void ServiceOptions::SerializeToOstream(std::ostream* output__) const {
+void ServiceOptions::SerializeToOstream(OutputStream* output__) const {
   if (has_features_) {
     WriteLengthDelimited(output__, 34,
                          features_.ByteSizeLong());
@@ -2322,7 +2323,7 @@
   has_options_ = false;
 }
 
-void ServiceDescriptorProto::SerializeToOstream(std::ostream* output__) const {
+void ServiceDescriptorProto::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   for (const auto& elem : method_) {
     if (has_method_) {
@@ -2384,7 +2385,7 @@
   has_uninterpreted_option_ = false;
 }
 
-void MethodOptions::SerializeToOstream(std::ostream* output__) const {
+void MethodOptions::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32(output__, 33, deprecated_);
   WriteVarint32SignExtended(output__, 34, static_cast<int32_t>(idempotency_level_));
   if (has_features_) {
@@ -2456,7 +2457,7 @@
   server_streaming_ = static_cast< bool >(0);
 }
 
-void MethodDescriptorProto::SerializeToOstream(std::ostream* output__) const {
+void MethodDescriptorProto::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   WriteString(output__, 2, input_type_);
   WriteString(output__, 3, output_type_);
@@ -2526,7 +2527,7 @@
   is_extension_ = static_cast< bool >(0);
 }
 
-void UninterpretedOption::NamePart::SerializeToOstream(std::ostream* output__) const {
+void UninterpretedOption::NamePart::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_part_);
   WriteVarint32(output__, 2, is_extension_);
 }
@@ -2566,7 +2567,7 @@
   has_aggregate_value_ = false;
 }
 
-void UninterpretedOption::SerializeToOstream(std::ostream* output__) const {
+void UninterpretedOption::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : name_) {
     if (has_name_) {
       WriteLengthDelimited(output__, 2,
@@ -2653,7 +2654,7 @@
   has_fixed_features_ = false;
 }
 
-void FeatureSetDefaults::FeatureSetEditionDefault::SerializeToOstream(std::ostream* output__) const {
+void FeatureSetDefaults::FeatureSetEditionDefault::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 3, static_cast<int32_t>(edition_));
   if (has_overridable_features_) {
     WriteLengthDelimited(output__, 4,
@@ -2706,7 +2707,7 @@
   maximum_edition_ = static_cast< ::rs::google::protobuf::Edition >(0);
 }
 
-void FeatureSetDefaults::SerializeToOstream(std::ostream* output__) const {
+void FeatureSetDefaults::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : defaults_) {
     if (has_defaults_) {
       WriteLengthDelimited(output__, 1,
@@ -2765,7 +2766,7 @@
   semantic_ = static_cast< ::rs::google::protobuf::GeneratedCodeInfo::Annotation::Semantic >(0);
 }
 
-void GeneratedCodeInfo::Annotation::SerializeToOstream(std::ostream* output__) const {
+void GeneratedCodeInfo::Annotation::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : path_) {
     WriteVarint32SignExtended(output__, 1, elem);
   }
@@ -2828,7 +2829,7 @@
   has_annotation_ = false;
 }
 
-void GeneratedCodeInfo::SerializeToOstream(std::ostream* output__) const {
+void GeneratedCodeInfo::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : annotation_) {
     if (has_annotation_) {
       WriteLengthDelimited(output__, 1,
@@ -2879,7 +2880,7 @@
   nanos_ = static_cast< int32_t >(0);
 }
 
-void Duration::SerializeToOstream(std::ostream* output__) const {
+void Duration::SerializeToOstream(OutputStream* output__) const {
   WriteVarint64(output__, 1, seconds_);
   WriteVarint32SignExtended(output__, 2, nanos_);
 }
@@ -2916,7 +2917,7 @@
   generate_omitted_as_internal_ = static_cast< bool >(0);
 }
 
-void SelectiveGapicGeneration::SerializeToOstream(std::ostream* output__) const {
+void SelectiveGapicGeneration::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : methods_) {
     WriteString(output__, 1, elem);
   }
@@ -2957,7 +2958,7 @@
   has_selective_gapic_generation_ = false;
 }
 
-void CommonLanguageSettings::SerializeToOstream(std::ostream* output__) const {
+void CommonLanguageSettings::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, reference_docs_uri_);
   for (const auto& elem : destinations_) {
     WriteVarint32SignExtended(output__, 2, static_cast<int32_t>(elem));
@@ -3009,7 +3010,7 @@
   has_common_ = false;
 }
 
-void CppSettings::SerializeToOstream(std::ostream* output__) const {
+void CppSettings::SerializeToOstream(OutputStream* output__) const {
   if (has_common_) {
     WriteLengthDelimited(output__, 1,
                          common_.ByteSizeLong());
@@ -3038,7 +3039,7 @@
   has_value_ = false;
 }
 
-void DotnetSettings::RenamedServicesEntry::SerializeToOstream(std::ostream* output__) const {
+void DotnetSettings::RenamedServicesEntry::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, key_);
   WriteString(output__, 2, value_);
 }
@@ -3070,7 +3071,7 @@
   has_value_ = false;
 }
 
-void DotnetSettings::RenamedResourcesEntry::SerializeToOstream(std::ostream* output__) const {
+void DotnetSettings::RenamedResourcesEntry::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, key_);
   WriteString(output__, 2, value_);
 }
@@ -3106,7 +3107,7 @@
   has_handwritten_signatures_ = false;
 }
 
-void DotnetSettings::SerializeToOstream(std::ostream* output__) const {
+void DotnetSettings::SerializeToOstream(OutputStream* output__) const {
   if (has_common_) {
     WriteLengthDelimited(output__, 1,
                          common_.ByteSizeLong());
@@ -3225,7 +3226,7 @@
   has_value_ = false;
 }
 
-void GoSettings::RenamedServicesEntry::SerializeToOstream(std::ostream* output__) const {
+void GoSettings::RenamedServicesEntry::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, key_);
   WriteString(output__, 2, value_);
 }
@@ -3257,7 +3258,7 @@
   has_renamed_services_ = false;
 }
 
-void GoSettings::SerializeToOstream(std::ostream* output__) const {
+void GoSettings::SerializeToOstream(OutputStream* output__) const {
   if (has_common_) {
     WriteLengthDelimited(output__, 1,
                          common_.ByteSizeLong());
@@ -3307,7 +3308,7 @@
   has_value_ = false;
 }
 
-void JavaSettings::ServiceClassNamesEntry::SerializeToOstream(std::ostream* output__) const {
+void JavaSettings::ServiceClassNamesEntry::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, key_);
   WriteString(output__, 2, value_);
 }
@@ -3340,7 +3341,7 @@
   has_common_ = false;
 }
 
-void JavaSettings::SerializeToOstream(std::ostream* output__) const {
+void JavaSettings::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, library_package_);
   for (const auto& elem : service_class_names_) {
     if (has_service_class_names_) {
@@ -3397,7 +3398,7 @@
   has_common_ = false;
 }
 
-void NodeSettings::SerializeToOstream(std::ostream* output__) const {
+void NodeSettings::SerializeToOstream(OutputStream* output__) const {
   if (has_common_) {
     WriteLengthDelimited(output__, 1,
                          common_.ByteSizeLong());
@@ -3425,7 +3426,7 @@
   has_common_ = false;
 }
 
-void PhpSettings::SerializeToOstream(std::ostream* output__) const {
+void PhpSettings::SerializeToOstream(OutputStream* output__) const {
   if (has_common_) {
     WriteLengthDelimited(output__, 1,
                          common_.ByteSizeLong());
@@ -3458,7 +3459,7 @@
   unversioned_package_disabled_ = static_cast< bool >(0);
 }
 
-void PythonSettings::ExperimentalFeatures::SerializeToOstream(std::ostream* output__) const {
+void PythonSettings::ExperimentalFeatures::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32(output__, 1, rest_async_io_enabled_);
   WriteVarint32(output__, 2, protobuf_pythonic_types_enabled_);
   WriteVarint32(output__, 3, unversioned_package_disabled_);
@@ -3498,7 +3499,7 @@
   has_experimental_features_ = false;
 }
 
-void PythonSettings::SerializeToOstream(std::ostream* output__) const {
+void PythonSettings::SerializeToOstream(OutputStream* output__) const {
   if (has_common_) {
     WriteLengthDelimited(output__, 1,
                          common_.ByteSizeLong());
@@ -3539,7 +3540,7 @@
   has_common_ = false;
 }
 
-void RubySettings::SerializeToOstream(std::ostream* output__) const {
+void RubySettings::SerializeToOstream(OutputStream* output__) const {
   if (has_common_) {
     WriteLengthDelimited(output__, 1,
                          common_.ByteSizeLong());
@@ -3579,7 +3580,7 @@
   has_go_settings_ = false;
 }
 
-void ClientLibrarySettings::SerializeToOstream(std::ostream* output__) const {
+void ClientLibrarySettings::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, version_);
   WriteVarint32SignExtended(output__, 2, static_cast<int32_t>(launch_stage_));
   WriteVarint32(output__, 3, rest_numeric_enums_);
@@ -3733,7 +3734,7 @@
   has_rest_reference_documentation_uri_ = false;
 }
 
-void Publishing::SerializeToOstream(std::ostream* output__) const {
+void Publishing::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : method_settings_) {
     if (has_method_settings_) {
       WriteLengthDelimited(output__, 2,
@@ -3874,7 +3875,7 @@
   has_total_poll_timeout_ = false;
 }
 
-void MethodSettings::LongRunning::SerializeToOstream(std::ostream* output__) const {
+void MethodSettings::LongRunning::SerializeToOstream(OutputStream* output__) const {
   if (has_initial_poll_delay_) {
     WriteLengthDelimited(output__, 1,
                          initial_poll_delay_.ByteSizeLong());
@@ -3938,7 +3939,7 @@
   has_auto_populated_fields_ = false;
 }
 
-void MethodSettings::SerializeToOstream(std::ostream* output__) const {
+void MethodSettings::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, selector_);
   if (has_long_running_) {
     WriteLengthDelimited(output__, 2,
@@ -4005,7 +4006,7 @@
   has_style_ = false;
 }
 
-void ResourceDescriptor::SerializeToOstream(std::ostream* output__) const {
+void ResourceDescriptor::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, type_);
   for (const auto& elem : pattern_) {
     WriteString(output__, 2, elem);
@@ -4093,7 +4094,7 @@
   has_child_type_ = false;
 }
 
-void ResourceReference::SerializeToOstream(std::ostream* output__) const {
+void ResourceReference::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, type_);
   WriteString(output__, 2, child_type_);
 }
@@ -4131,7 +4132,7 @@
   nanos_ = static_cast< int32_t >(0);
 }
 
-void Timestamp::SerializeToOstream(std::ostream* output__) const {
+void Timestamp::SerializeToOstream(OutputStream* output__) const {
   WriteVarint64(output__, 1, seconds_);
   WriteVarint32SignExtended(output__, 2, nanos_);
 }
@@ -4170,7 +4171,7 @@
   has_description_ = false;
 }
 
-void StatusAttributes::SerializeToOstream(std::ostream* output__) const {
+void StatusAttributes::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(status_));
   WriteString(output__, 2, description_);
 }
@@ -4202,7 +4203,7 @@
   has_value_ = false;
 }
 
-void Property::SerializeToOstream(std::ostream* output__) const {
+void Property::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, key_);
   WriteString(output__, 2, value_);
 }
@@ -4234,7 +4235,7 @@
   has_duration_ = false;
 }
 
-void Timing::SerializeToOstream(std::ostream* output__) const {
+void Timing::SerializeToOstream(OutputStream* output__) const {
   if (has_start_time_) {
     WriteLengthDelimited(output__, 1,
                          start_time_.ByteSizeLong());
@@ -4277,7 +4278,7 @@
   has_action_id_ = false;
 }
 
-void Dependency::Id::SerializeToOstream(std::ostream* output__) const {
+void Dependency::Id::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 2, target_id_);
   WriteString(output__, 3, configuration_id_);
   WriteString(output__, 4, action_id_);
@@ -4320,7 +4321,7 @@
   has_label_ = false;
 }
 
-void Dependency::SerializeToOstream(std::ostream* output__) const {
+void Dependency::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, target_);
   WriteString(output__, 2, configured_target_);
   WriteString(output__, 3, action_);
@@ -4389,7 +4390,7 @@
   has_executed_lines_ = false;
 }
 
-void LineCoverage::SerializeToOstream(std::ostream* output__) const {
+void LineCoverage::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, instrumented_lines_);
   WriteString(output__, 2, executed_lines_);
 }
@@ -4423,7 +4424,7 @@
   has_taken_ = false;
 }
 
-void BranchCoverage::SerializeToOstream(std::ostream* output__) const {
+void BranchCoverage::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, branch_present_);
   for (const auto& elem : branches_in_line_) {
     WriteVarint32SignExtended(output__, 2, elem);
@@ -4480,7 +4481,7 @@
   has_branch_coverage_ = false;
 }
 
-void FileCoverage::SerializeToOstream(std::ostream* output__) const {
+void FileCoverage::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, path_);
   if (has_line_coverage_) {
     WriteLengthDelimited(output__, 2,
@@ -4529,7 +4530,7 @@
   has_file_coverages_ = false;
 }
 
-void ActionCoverage::SerializeToOstream(std::ostream* output__) const {
+void ActionCoverage::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : file_coverages_) {
     if (has_file_coverages_) {
       WriteLengthDelimited(output__, 2,
@@ -4565,7 +4566,7 @@
   has_file_coverages_ = false;
 }
 
-void AggregateCoverage::SerializeToOstream(std::ostream* output__) const {
+void AggregateCoverage::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : file_coverages_) {
     if (has_file_coverages_) {
       WriteLengthDelimited(output__, 1,
@@ -4608,7 +4609,7 @@
   value_ = static_cast< double >(0);
 }
 
-void DoubleValue::SerializeToOstream(std::ostream* output__) const {
+void DoubleValue::SerializeToOstream(OutputStream* output__) const {
   WriteFixed64(output__, 1, static_cast<uint64_t>(value_));
 }
 
@@ -4632,7 +4633,7 @@
   value_ = static_cast< float >(0);
 }
 
-void FloatValue::SerializeToOstream(std::ostream* output__) const {
+void FloatValue::SerializeToOstream(OutputStream* output__) const {
   WriteFixed32(output__, 1, static_cast<uint32_t>(value_));
 }
 
@@ -4656,7 +4657,7 @@
   value_ = static_cast< int64_t >(0);
 }
 
-void Int64Value::SerializeToOstream(std::ostream* output__) const {
+void Int64Value::SerializeToOstream(OutputStream* output__) const {
   WriteVarint64(output__, 1, value_);
 }
 
@@ -4680,7 +4681,7 @@
   value_ = static_cast< uint64_t >(0);
 }
 
-void UInt64Value::SerializeToOstream(std::ostream* output__) const {
+void UInt64Value::SerializeToOstream(OutputStream* output__) const {
   WriteVarint64(output__, 1, value_);
 }
 
@@ -4704,7 +4705,7 @@
   value_ = static_cast< int32_t >(0);
 }
 
-void Int32Value::SerializeToOstream(std::ostream* output__) const {
+void Int32Value::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, value_);
 }
 
@@ -4728,7 +4729,7 @@
   value_ = static_cast< uint32_t >(0);
 }
 
-void UInt32Value::SerializeToOstream(std::ostream* output__) const {
+void UInt32Value::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32(output__, 1, value_);
 }
 
@@ -4752,7 +4753,7 @@
   value_ = static_cast< bool >(0);
 }
 
-void BoolValue::SerializeToOstream(std::ostream* output__) const {
+void BoolValue::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32(output__, 1, value_);
 }
 
@@ -4775,7 +4776,7 @@
   has_value_ = false;
 }
 
-void StringValue::SerializeToOstream(std::ostream* output__) const {
+void StringValue::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, value_);
 }
 
@@ -4798,7 +4799,7 @@
   has_value_ = false;
 }
 
-void BytesValue::SerializeToOstream(std::ostream* output__) const {
+void BytesValue::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, value_);
 }
 
@@ -4829,7 +4830,7 @@
   has_content_type_ = false;
 }
 
-void ArchiveEntry::SerializeToOstream(std::ostream* output__) const {
+void ArchiveEntry::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, path_);
   if (has_length_) {
     WriteLengthDelimited(output__, 2,
@@ -4884,7 +4885,7 @@
   hash_type_ = static_cast< ::rs::google::devtools::resultstore::v2::File::HashType >(0);
 }
 
-void File::SerializeToOstream(std::ostream* output__) const {
+void File::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, uid_);
   WriteString(output__, 2, uri_);
   if (has_length_) {
@@ -4998,7 +4999,7 @@
   has_file_processing_errors_ = false;
 }
 
-void FileProcessingErrors::SerializeToOstream(std::ostream* output__) const {
+void FileProcessingErrors::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, file_uid_);
   for (const auto& elem : file_processing_errors_) {
     if (has_file_processing_errors_) {
@@ -5044,7 +5045,7 @@
   has_message_ = false;
 }
 
-void FileProcessingError::SerializeToOstream(std::ostream* output__) const {
+void FileProcessingError::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(type_));
   WriteString(output__, 2, message_);
 }
@@ -5089,7 +5090,7 @@
   has_files_ = false;
 }
 
-void TestSuite::SerializeToOstream(std::ostream* output__) const {
+void TestSuite::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, suite_name_);
   for (const auto& elem : tests_) {
     if (has_tests_) {
@@ -5242,7 +5243,7 @@
   repeat_number_ = static_cast< int32_t >(0);
 }
 
-void TestCase::SerializeToOstream(std::ostream* output__) const {
+void TestCase::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, case_name_);
   WriteString(output__, 2, class_name_);
   WriteVarint32SignExtended(output__, 3, static_cast<int32_t>(result_));
@@ -5395,7 +5396,7 @@
   has_test_suite_ = false;
 }
 
-void Test::SerializeToOstream(std::ostream* output__) const {
+void Test::SerializeToOstream(OutputStream* output__) const {
   if (has_test_case_) {
     WriteLengthDelimited(output__, 1,
                          test_case_.ByteSizeLong());
@@ -5440,7 +5441,7 @@
   has_actual_ = false;
 }
 
-void TestFailure::SerializeToOstream(std::ostream* output__) const {
+void TestFailure::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, failure_message_);
   WriteString(output__, 2, exception_type_);
   WriteString(output__, 3, stack_trace_);
@@ -5513,7 +5514,7 @@
   has_stack_trace_ = false;
 }
 
-void TestError::SerializeToOstream(std::ostream* output__) const {
+void TestError::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, error_message_);
   WriteString(output__, 2, exception_type_);
   WriteString(output__, 3, stack_trace_);
@@ -5569,7 +5570,7 @@
   distinct_byte_limit_ = static_cast< int64_t >(0);
 }
 
-void InputFileInfo::SerializeToOstream(std::ostream* output__) const {
+void InputFileInfo::SerializeToOstream(OutputStream* output__) const {
   WriteVarint64(output__, 1, count_);
   WriteVarint64(output__, 2, distinct_count_);
   WriteVarint64(output__, 3, count_limit_);
@@ -5629,7 +5630,7 @@
   has_input_file_info_ = false;
 }
 
-void ActionAttributes::SerializeToOstream(std::ostream* output__) const {
+void ActionAttributes::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(execution_strategy_));
   WriteVarint32SignExtended(output__, 2, exit_code_);
   WriteString(output__, 3, hostname_);
@@ -5683,7 +5684,7 @@
   has_primary_output_path_ = false;
 }
 
-void BuildAction::SerializeToOstream(std::ostream* output__) const {
+void BuildAction::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, type_);
   WriteString(output__, 2, primary_input_path_);
   WriteString(output__, 3, primary_output_path_);
@@ -5722,7 +5723,7 @@
   has_test_process_duration_ = false;
 }
 
-void LocalTestTiming::SerializeToOstream(std::ostream* output__) const {
+void LocalTestTiming::SerializeToOstream(OutputStream* output__) const {
   if (has_test_process_duration_) {
     WriteLengthDelimited(output__, 1,
                          test_process_duration_.ByteSizeLong());
@@ -5751,7 +5752,7 @@
   has_attempts_ = false;
 }
 
-void RemoteTestTiming::SerializeToOstream(std::ostream* output__) const {
+void RemoteTestTiming::SerializeToOstream(OutputStream* output__) const {
   if (has_local_analysis_duration_) {
     WriteLengthDelimited(output__, 1,
                          local_analysis_duration_.ByteSizeLong());
@@ -5805,7 +5806,7 @@
   test_caching_ = static_cast< ::rs::google::devtools::resultstore::v2::TestCaching >(0);
 }
 
-void TestTiming::SerializeToOstream(std::ostream* output__) const {
+void TestTiming::SerializeToOstream(OutputStream* output__) const {
   if (has_local_) {
     WriteLengthDelimited(output__, 1,
                          local_.ByteSizeLong());
@@ -5890,7 +5891,7 @@
   estimated_memory_bytes_ = static_cast< int64_t >(0);
 }
 
-void TestAction::SerializeToOstream(std::ostream* output__) const {
+void TestAction::SerializeToOstream(OutputStream* output__) const {
   if (has_test_timing_) {
     WriteLengthDelimited(output__, 1,
                          test_timing_.ByteSizeLong());
@@ -5987,7 +5988,7 @@
   has_action_id_ = false;
 }
 
-void Action::Id::SerializeToOstream(std::ostream* output__) const {
+void Action::Id::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, invocation_id_);
   WriteString(output__, 2, target_id_);
   WriteString(output__, 3, configuration_id_);
@@ -6046,7 +6047,7 @@
   has_file_processing_errors_ = false;
 }
 
-void Action::SerializeToOstream(std::ostream* output__) const {
+void Action::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   if (has_id_) {
     WriteLengthDelimited(output__, 2,
@@ -6264,7 +6265,7 @@
   has_download_duration_ = false;
 }
 
-void RemoteTestAttemptTiming::SerializeToOstream(std::ostream* output__) const {
+void RemoteTestAttemptTiming::SerializeToOstream(OutputStream* output__) const {
   if (has_queue_duration_) {
     WriteLengthDelimited(output__, 1,
                          queue_duration_.ByteSizeLong());
@@ -6344,7 +6345,7 @@
   has_warning_message_ = false;
 }
 
-void TestWarning::SerializeToOstream(std::ostream* output__) const {
+void TestWarning::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, warning_message_);
 }
 
@@ -6375,7 +6376,7 @@
   has_cpu_ = false;
 }
 
-void ConfigurationAttributes::SerializeToOstream(std::ostream* output__) const {
+void ConfigurationAttributes::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, cpu_);
 }
 
@@ -6399,7 +6400,7 @@
   has_configuration_id_ = false;
 }
 
-void Configuration::Id::SerializeToOstream(std::ostream* output__) const {
+void Configuration::Id::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, invocation_id_);
   WriteString(output__, 2, configuration_id_);
 }
@@ -6435,7 +6436,7 @@
   has_display_name_ = false;
 }
 
-void Configuration::SerializeToOstream(std::ostream* output__) const {
+void Configuration::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   if (has_id_) {
     WriteLengthDelimited(output__, 2,
@@ -6538,7 +6539,7 @@
   has_timeout_duration_ = false;
 }
 
-void ConfiguredTestAttributes::SerializeToOstream(std::ostream* output__) const {
+void ConfiguredTestAttributes::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 2, total_run_count_);
   WriteVarint32SignExtended(output__, 3, total_shard_count_);
   if (has_timeout_duration_) {
@@ -6584,7 +6585,7 @@
   has_configuration_id_ = false;
 }
 
-void ConfiguredTarget::Id::SerializeToOstream(std::ostream* output__) const {
+void ConfiguredTarget::Id::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, invocation_id_);
   WriteString(output__, 2, target_id_);
   WriteString(output__, 3, configuration_id_);
@@ -6629,7 +6630,7 @@
   has_files_ = false;
 }
 
-void ConfiguredTarget::SerializeToOstream(std::ostream* output__) const {
+void ConfiguredTarget::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   if (has_id_) {
     WriteLengthDelimited(output__, 2,
@@ -6755,7 +6756,7 @@
   has_file_set_id_ = false;
 }
 
-void FileSet::Id::SerializeToOstream(std::ostream* output__) const {
+void FileSet::Id::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, invocation_id_);
   WriteString(output__, 2, file_set_id_);
 }
@@ -6789,7 +6790,7 @@
   has_files_ = false;
 }
 
-void FileSet::SerializeToOstream(std::ostream* output__) const {
+void FileSet::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   if (has_id_) {
     WriteLengthDelimited(output__, 2,
@@ -6873,7 +6874,7 @@
   executed_line_count_ = static_cast< int32_t >(0);
 }
 
-void LineCoverageSummary::SerializeToOstream(std::ostream* output__) const {
+void LineCoverageSummary::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, instrumented_line_count_);
   WriteVarint32SignExtended(output__, 2, executed_line_count_);
 }
@@ -6909,7 +6910,7 @@
   taken_branch_count_ = static_cast< int32_t >(0);
 }
 
-void BranchCoverageSummary::SerializeToOstream(std::ostream* output__) const {
+void BranchCoverageSummary::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, total_branch_count_);
   WriteVarint32SignExtended(output__, 2, executed_branch_count_);
   WriteVarint32SignExtended(output__, 3, taken_branch_count_);
@@ -6951,7 +6952,7 @@
   has_branch_summary_ = false;
 }
 
-void LanguageCoverageSummary::SerializeToOstream(std::ostream* output__) const {
+void LanguageCoverageSummary::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(language_));
   if (has_line_summary_) {
     WriteLengthDelimited(output__, 2,
@@ -7014,7 +7015,7 @@
   exit_code_ = static_cast< int32_t >(0);
 }
 
-void InvocationAttributes::SerializeToOstream(std::ostream* output__) const {
+void InvocationAttributes::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, project_id_);
   for (const auto& elem : users_) {
     WriteString(output__, 2, elem);
@@ -7105,7 +7106,7 @@
 WorkspaceContext::WorkspaceContext() {
 }
 
-void WorkspaceContext::SerializeToOstream(std::ostream* output__) const {
+void WorkspaceContext::SerializeToOstream(OutputStream* output__) const {
 }
 
 size_t WorkspaceContext::ByteSizeLong() const {
@@ -7124,7 +7125,7 @@
   has_command_lines_ = false;
 }
 
-void WorkspaceInfo::SerializeToOstream(std::ostream* output__) const {
+void WorkspaceInfo::SerializeToOstream(OutputStream* output__) const {
   if (has_workspace_context_) {
     WriteLengthDelimited(output__, 1,
                          workspace_context_.ByteSizeLong());
@@ -7197,7 +7198,7 @@
   has_invocation_id_ = false;
 }
 
-void Invocation::Id::SerializeToOstream(std::ostream* output__) const {
+void Invocation::Id::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, invocation_id_);
 }
 
@@ -7230,7 +7231,7 @@
   has_file_processing_errors_ = false;
 }
 
-void Invocation::SerializeToOstream(std::ostream* output__) const {
+void Invocation::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   if (has_id_) {
     WriteLengthDelimited(output__, 2,
@@ -7418,7 +7419,7 @@
   has_command_ = false;
 }
 
-void CommandLine::SerializeToOstream(std::ostream* output__) const {
+void CommandLine::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, label_);
   WriteString(output__, 2, tool_);
   for (const auto& elem : args_) {
@@ -7474,7 +7475,7 @@
   has_url_ = false;
 }
 
-void InvocationContext::SerializeToOstream(std::ostream* output__) const {
+void InvocationContext::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, display_name_);
   WriteString(output__, 2, url_);
 }
@@ -7517,7 +7518,7 @@
   has_tags_ = false;
 }
 
-void TargetAttributes::SerializeToOstream(std::ostream* output__) const {
+void TargetAttributes::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(type_));
   WriteVarint32SignExtended(output__, 2, static_cast<int32_t>(language_));
   for (const auto& elem : tags_) {
@@ -7565,7 +7566,7 @@
   size_ = static_cast< ::rs::google::devtools::resultstore::v2::TestSize >(0);
 }
 
-void TestAttributes::SerializeToOstream(std::ostream* output__) const {
+void TestAttributes::SerializeToOstream(OutputStream* output__) const {
   WriteVarint32SignExtended(output__, 1, static_cast<int32_t>(size_));
 }
 
@@ -7589,7 +7590,7 @@
   has_target_id_ = false;
 }
 
-void Target::Id::SerializeToOstream(std::ostream* output__) const {
+void Target::Id::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, invocation_id_);
   WriteString(output__, 2, target_id_);
 }
@@ -7629,7 +7630,7 @@
   visible_ = static_cast< bool >(0);
 }
 
-void Target::SerializeToOstream(std::ostream* output__) const {
+void Target::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   if (has_id_) {
     WriteLengthDelimited(output__, 2,
@@ -7777,7 +7778,7 @@
   has_uploader_state_ = false;
 }
 
-void UploadMetadata::SerializeToOstream(std::ostream* output__) const {
+void UploadMetadata::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   WriteString(output__, 2, resume_token_);
   WriteString(output__, 3, uploader_state_);
@@ -7821,7 +7822,7 @@
 Empty::Empty() {
 }
 
-void Empty::SerializeToOstream(std::ostream* output__) const {
+void Empty::SerializeToOstream(OutputStream* output__) const {
 }
 
 size_t Empty::ByteSizeLong() const {
@@ -7840,7 +7841,7 @@
   has_paths_ = false;
 }
 
-void FieldMask::SerializeToOstream(std::ostream* output__) const {
+void FieldMask::SerializeToOstream(OutputStream* output__) const {
   for (const auto& elem : paths_) {
     WriteString(output__, 1, elem);
   }
@@ -7883,7 +7884,7 @@
   has_uploader_state_ = false;
 }
 
-void CreateInvocationRequest::SerializeToOstream(std::ostream* output__) const {
+void CreateInvocationRequest::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, request_id_);
   WriteString(output__, 2, invocation_id_);
   if (has_invocation_) {
@@ -7966,7 +7967,7 @@
   has_authorization_token_ = false;
 }
 
-void UpdateInvocationRequest::SerializeToOstream(std::ostream* output__) const {
+void UpdateInvocationRequest::SerializeToOstream(OutputStream* output__) const {
   if (has_invocation_) {
     WriteLengthDelimited(output__, 3,
                          invocation_.ByteSizeLong());
@@ -8018,7 +8019,7 @@
   has_authorization_token_ = false;
 }
 
-void MergeInvocationRequest::SerializeToOstream(std::ostream* output__) const {
+void MergeInvocationRequest::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, request_id_);
   if (has_invocation_) {
     WriteLengthDelimited(output__, 3,
@@ -8076,7 +8077,7 @@
   has_authorization_token_ = false;
 }
 
-void TouchInvocationRequest::SerializeToOstream(std::ostream* output__) const {
+void TouchInvocationRequest::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   WriteString(output__, 2, authorization_token_);
 }
@@ -8108,7 +8109,7 @@
   has_id_ = false;
 }
 
-void TouchInvocationResponse::SerializeToOstream(std::ostream* output__) const {
+void TouchInvocationResponse::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   if (has_id_) {
     WriteLengthDelimited(output__, 2,
@@ -8144,7 +8145,7 @@
   has_name_ = false;
 }
 
-void DeleteInvocationRequest::SerializeToOstream(std::ostream* output__) const {
+void DeleteInvocationRequest::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
 }
 
@@ -8168,7 +8169,7 @@
   has_authorization_token_ = false;
 }
 
-void FinalizeInvocationRequest::SerializeToOstream(std::ostream* output__) const {
+void FinalizeInvocationRequest::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   WriteString(output__, 3, authorization_token_);
 }
@@ -8200,7 +8201,7 @@
   has_id_ = false;
 }
 
-void FinalizeInvocationResponse::SerializeToOstream(std::ostream* output__) const {
+void FinalizeInvocationResponse::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   if (has_id_) {
     WriteLengthDelimited(output__, 2,
@@ -8240,7 +8241,7 @@
   has_authorization_token_ = false;
 }
 
-void CreateTargetRequest::SerializeToOstream(std::ostream* output__) const {
+void CreateTargetRequest::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, request_id_);
   WriteString(output__, 2, parent_);
   WriteString(output__, 3, target_id_);
@@ -8304,7 +8305,7 @@
   create_if_not_found_ = static_cast< bool >(0);
 }
 
-void UpdateTargetRequest::SerializeToOstream(std::ostream* output__) const {
+void UpdateTargetRequest::SerializeToOstream(OutputStream* output__) const {
   if (has_target_) {
     WriteLengthDelimited(output__, 3,
                          target_.ByteSizeLong());
@@ -8366,7 +8367,7 @@
   create_if_not_found_ = static_cast< bool >(0);
 }
 
-void MergeTargetRequest::SerializeToOstream(std::ostream* output__) const {
+void MergeTargetRequest::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, request_id_);
   if (has_target_) {
     WriteLengthDelimited(output__, 3,
@@ -8432,7 +8433,7 @@
   has_authorization_token_ = false;
 }
 
-void FinalizeTargetRequest::SerializeToOstream(std::ostream* output__) const {
+void FinalizeTargetRequest::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   WriteString(output__, 3, authorization_token_);
 }
@@ -8464,7 +8465,7 @@
   has_id_ = false;
 }
 
-void FinalizeTargetResponse::SerializeToOstream(std::ostream* output__) const {
+void FinalizeTargetResponse::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   if (has_id_) {
     WriteLengthDelimited(output__, 2,
@@ -8504,7 +8505,7 @@
   has_authorization_token_ = false;
 }
 
-void CreateConfiguredTargetRequest::SerializeToOstream(std::ostream* output__) const {
+void CreateConfiguredTargetRequest::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, request_id_);
   WriteString(output__, 2, parent_);
   WriteString(output__, 3, config_id_);
@@ -8568,7 +8569,7 @@
   create_if_not_found_ = static_cast< bool >(0);
 }
 
-void UpdateConfiguredTargetRequest::SerializeToOstream(std::ostream* output__) const {
+void UpdateConfiguredTargetRequest::SerializeToOstream(OutputStream* output__) const {
   if (has_configured_target_) {
     WriteLengthDelimited(output__, 3,
                          configured_target_.ByteSizeLong());
@@ -8630,7 +8631,7 @@
   create_if_not_found_ = static_cast< bool >(0);
 }
 
-void MergeConfiguredTargetRequest::SerializeToOstream(std::ostream* output__) const {
+void MergeConfiguredTargetRequest::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, request_id_);
   if (has_configured_target_) {
     WriteLengthDelimited(output__, 3,
@@ -8696,7 +8697,7 @@
   has_authorization_token_ = false;
 }
 
-void FinalizeConfiguredTargetRequest::SerializeToOstream(std::ostream* output__) const {
+void FinalizeConfiguredTargetRequest::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   WriteString(output__, 3, authorization_token_);
 }
@@ -8728,7 +8729,7 @@
   has_id_ = false;
 }
 
-void FinalizeConfiguredTargetResponse::SerializeToOstream(std::ostream* output__) const {
+void FinalizeConfiguredTargetResponse::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   if (has_id_) {
     WriteLengthDelimited(output__, 2,
@@ -8768,7 +8769,7 @@
   has_authorization_token_ = false;
 }
 
-void CreateActionRequest::SerializeToOstream(std::ostream* output__) const {
+void CreateActionRequest::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, request_id_);
   WriteString(output__, 2, parent_);
   WriteString(output__, 3, action_id_);
@@ -8832,7 +8833,7 @@
   create_if_not_found_ = static_cast< bool >(0);
 }
 
-void UpdateActionRequest::SerializeToOstream(std::ostream* output__) const {
+void UpdateActionRequest::SerializeToOstream(OutputStream* output__) const {
   if (has_action_) {
     WriteLengthDelimited(output__, 3,
                          action_.ByteSizeLong());
@@ -8894,7 +8895,7 @@
   create_if_not_found_ = static_cast< bool >(0);
 }
 
-void MergeActionRequest::SerializeToOstream(std::ostream* output__) const {
+void MergeActionRequest::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, request_id_);
   if (has_action_) {
     WriteLengthDelimited(output__, 3,
@@ -8963,7 +8964,7 @@
   has_authorization_token_ = false;
 }
 
-void CreateConfigurationRequest::SerializeToOstream(std::ostream* output__) const {
+void CreateConfigurationRequest::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, request_id_);
   WriteString(output__, 2, parent_);
   WriteString(output__, 3, config_id_);
@@ -9027,7 +9028,7 @@
   create_if_not_found_ = static_cast< bool >(0);
 }
 
-void UpdateConfigurationRequest::SerializeToOstream(std::ostream* output__) const {
+void UpdateConfigurationRequest::SerializeToOstream(OutputStream* output__) const {
   if (has_configuration_) {
     WriteLengthDelimited(output__, 3,
                          configuration_.ByteSizeLong());
@@ -9088,7 +9089,7 @@
   has_authorization_token_ = false;
 }
 
-void CreateFileSetRequest::SerializeToOstream(std::ostream* output__) const {
+void CreateFileSetRequest::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, request_id_);
   WriteString(output__, 2, parent_);
   WriteString(output__, 3, file_set_id_);
@@ -9152,7 +9153,7 @@
   create_if_not_found_ = static_cast< bool >(0);
 }
 
-void UpdateFileSetRequest::SerializeToOstream(std::ostream* output__) const {
+void UpdateFileSetRequest::SerializeToOstream(OutputStream* output__) const {
   if (has_file_set_) {
     WriteLengthDelimited(output__, 1,
                          file_set_.ByteSizeLong());
@@ -9214,7 +9215,7 @@
   create_if_not_found_ = static_cast< bool >(0);
 }
 
-void MergeFileSetRequest::SerializeToOstream(std::ostream* output__) const {
+void MergeFileSetRequest::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, request_id_);
   if (has_file_set_) {
     WriteLengthDelimited(output__, 2,
@@ -9284,7 +9285,7 @@
   has_upload_requests_ = false;
 }
 
-void UploadBatchRequest::SerializeToOstream(std::ostream* output__) const {
+void UploadBatchRequest::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, parent_);
   WriteString(output__, 2, authorization_token_);
   WriteString(output__, 3, next_resume_token_);
@@ -9359,7 +9360,7 @@
 UploadBatchResponse::UploadBatchResponse() {
 }
 
-void UploadBatchResponse::SerializeToOstream(std::ostream* output__) const {
+void UploadBatchResponse::SerializeToOstream(OutputStream* output__) const {
 }
 
 size_t UploadBatchResponse::ByteSizeLong() const {
@@ -9377,7 +9378,7 @@
   has_file_set_id_ = false;
 }
 
-void UploadRequest::Id::SerializeToOstream(std::ostream* output__) const {
+void UploadRequest::Id::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, target_id_);
   WriteString(output__, 2, configuration_id_);
   WriteString(output__, 3, action_id_);
@@ -9435,7 +9436,7 @@
   has_file_set_ = false;
 }
 
-void UploadRequest::SerializeToOstream(std::ostream* output__) const {
+void UploadRequest::SerializeToOstream(OutputStream* output__) const {
   if (has_id_) {
     WriteLengthDelimited(output__, 1,
                          id_.ByteSizeLong());
@@ -9571,7 +9572,7 @@
   has_authorization_token_ = false;
 }
 
-void GetInvocationUploadMetadataRequest::SerializeToOstream(std::ostream* output__) const {
+void GetInvocationUploadMetadataRequest::SerializeToOstream(OutputStream* output__) const {
   WriteString(output__, 1, name_);
   WriteString(output__, 2, authorization_token_);
 }
diff --git a/src/resultstore.pb.h b/src/resultstore.pb.h
index 01a70ae..08452b4 100644
--- a/src/resultstore.pb.h
+++ b/src/resultstore.pb.h
@@ -1,14 +1,17 @@
 // This file is auto-generated by generate_proto_header.py, do not edit
 
+// clang-format off
+
 #ifndef NINJA_RESULTSTORE_PB_H
 #define NINJA_RESULTSTORE_PB_H
 
 #include <inttypes.h>
 
-#include <iosfwd>
 #include <string>
 #include <vector>
 
+struct OutputStream;
+
 namespace rs {
 namespace google {
 namespace api {
@@ -314,7 +317,7 @@
   Http(Http&&) = default;
   Http& operator=(const Http&) = default;
   Http& operator=(Http&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::rs::google::api::HttpRule >* mutable_rules() {
@@ -339,7 +342,7 @@
   CustomHttpPattern(CustomHttpPattern&&) = default;
   CustomHttpPattern& operator=(const CustomHttpPattern&) = default;
   CustomHttpPattern& operator=(CustomHttpPattern&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_kind() {
@@ -380,7 +383,7 @@
   HttpRule(HttpRule&&) = default;
   HttpRule& operator=(const HttpRule&) = default;
   HttpRule& operator=(HttpRule&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_selector() {
@@ -461,7 +464,7 @@
   FileDescriptorSet(FileDescriptorSet&&) = default;
   FileDescriptorSet& operator=(const FileDescriptorSet&) = default;
   FileDescriptorSet& operator=(FileDescriptorSet&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::rs::google::protobuf::FileDescriptorProto >* mutable_file() {
@@ -526,7 +529,7 @@
   FeatureSet(FeatureSet&&) = default;
   FeatureSet& operator=(const FeatureSet&) = default;
   FeatureSet& operator=(FeatureSet&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::protobuf::FeatureSet::FieldPresence* mutable_field_presence() {
@@ -615,7 +618,7 @@
   FileOptions(FileOptions&&) = default;
   FileOptions& operator=(const FileOptions&) = default;
   FileOptions& operator=(FileOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_java_package() {
@@ -741,7 +744,7 @@
     Location(Location&&) = default;
     Location& operator=(const Location&) = default;
     Location& operator=(Location&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::vector< int32_t >* mutable_path() {
@@ -781,7 +784,7 @@
   SourceCodeInfo(SourceCodeInfo&&) = default;
   SourceCodeInfo& operator=(const SourceCodeInfo&) = default;
   SourceCodeInfo& operator=(SourceCodeInfo&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::rs::google::protobuf::SourceCodeInfo::Location >* mutable_location() {
@@ -823,7 +826,7 @@
   FileDescriptorProto(FileDescriptorProto&&) = default;
   FileDescriptorProto& operator=(const FileDescriptorProto&) = default;
   FileDescriptorProto& operator=(FileDescriptorProto&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -916,7 +919,7 @@
     Declaration(Declaration&&) = default;
     Declaration& operator=(const Declaration&) = default;
     Declaration& operator=(Declaration&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     int32_t* mutable_number() {
@@ -959,7 +962,7 @@
   ExtensionRangeOptions(ExtensionRangeOptions&&) = default;
   ExtensionRangeOptions& operator=(const ExtensionRangeOptions&) = default;
   ExtensionRangeOptions& operator=(ExtensionRangeOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::rs::google::protobuf::UninterpretedOption >* mutable_uninterpreted_option() {
@@ -1003,7 +1006,7 @@
   MessageOptions(MessageOptions&&) = default;
   MessageOptions& operator=(const MessageOptions&) = default;
   MessageOptions& operator=(MessageOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   bool* mutable_message_set_wire_format() {
@@ -1055,7 +1058,7 @@
     ExtensionRange(ExtensionRange&&) = default;
     ExtensionRange& operator=(const ExtensionRange&) = default;
     ExtensionRange& operator=(ExtensionRange&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     int32_t* mutable_start() {
@@ -1084,7 +1087,7 @@
     ReservedRange(ReservedRange&&) = default;
     ReservedRange& operator=(const ReservedRange&) = default;
     ReservedRange& operator=(ReservedRange&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     int32_t* mutable_start() {
@@ -1124,7 +1127,7 @@
   DescriptorProto(DescriptorProto&&) = default;
   DescriptorProto& operator=(const DescriptorProto&) = default;
   DescriptorProto& operator=(DescriptorProto&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -1221,7 +1224,7 @@
     EditionDefault(EditionDefault&&) = default;
     EditionDefault& operator=(const EditionDefault&) = default;
     EditionDefault& operator=(EditionDefault&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     ::rs::google::protobuf::Edition* mutable_edition() {
@@ -1250,7 +1253,7 @@
     FeatureSupport(FeatureSupport&&) = default;
     FeatureSupport& operator=(const FeatureSupport&) = default;
     FeatureSupport& operator=(FeatureSupport&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     ::rs::google::protobuf::Edition* mutable_edition_introduced() {
@@ -1308,7 +1311,7 @@
   FieldOptions(FieldOptions&&) = default;
   FieldOptions& operator=(const FieldOptions&) = default;
   FieldOptions& operator=(FieldOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::protobuf::FieldOptions::CType* mutable_ctype() {
@@ -1437,7 +1440,7 @@
   FieldDescriptorProto(FieldDescriptorProto&&) = default;
   FieldDescriptorProto& operator=(const FieldDescriptorProto&) = default;
   FieldDescriptorProto& operator=(FieldDescriptorProto&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -1506,7 +1509,7 @@
   OneofOptions(OneofOptions&&) = default;
   OneofOptions& operator=(const OneofOptions&) = default;
   OneofOptions& operator=(OneofOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::protobuf::FeatureSet* mutable_features() {
@@ -1530,7 +1533,7 @@
   OneofDescriptorProto(OneofDescriptorProto&&) = default;
   OneofDescriptorProto& operator=(const OneofDescriptorProto&) = default;
   OneofDescriptorProto& operator=(OneofDescriptorProto&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -1560,7 +1563,7 @@
   EnumOptions(EnumOptions&&) = default;
   EnumOptions& operator=(const EnumOptions&) = default;
   EnumOptions& operator=(EnumOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   bool* mutable_allow_alias() {
@@ -1600,7 +1603,7 @@
     EnumReservedRange(EnumReservedRange&&) = default;
     EnumReservedRange& operator=(const EnumReservedRange&) = default;
     EnumReservedRange& operator=(EnumReservedRange&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     int32_t* mutable_start() {
@@ -1630,7 +1633,7 @@
   EnumDescriptorProto(EnumDescriptorProto&&) = default;
   EnumDescriptorProto& operator=(const EnumDescriptorProto&) = default;
   EnumDescriptorProto& operator=(EnumDescriptorProto&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -1676,7 +1679,7 @@
   EnumValueOptions(EnumValueOptions&&) = default;
   EnumValueOptions& operator=(const EnumValueOptions&) = default;
   EnumValueOptions& operator=(EnumValueOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   bool* mutable_deprecated() {
@@ -1716,7 +1719,7 @@
   EnumValueDescriptorProto(EnumValueDescriptorProto&&) = default;
   EnumValueDescriptorProto& operator=(const EnumValueDescriptorProto&) = default;
   EnumValueDescriptorProto& operator=(EnumValueDescriptorProto&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -1747,7 +1750,7 @@
   ServiceOptions(ServiceOptions&&) = default;
   ServiceOptions& operator=(const ServiceOptions&) = default;
   ServiceOptions& operator=(ServiceOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::protobuf::FeatureSet* mutable_features() {
@@ -1778,7 +1781,7 @@
   ServiceDescriptorProto(ServiceDescriptorProto&&) = default;
   ServiceDescriptorProto& operator=(const ServiceDescriptorProto&) = default;
   ServiceDescriptorProto& operator=(ServiceDescriptorProto&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -1817,7 +1820,7 @@
   MethodOptions(MethodOptions&&) = default;
   MethodOptions& operator=(const MethodOptions&) = default;
   MethodOptions& operator=(MethodOptions&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   bool* mutable_deprecated() {
@@ -1859,7 +1862,7 @@
   MethodDescriptorProto(MethodDescriptorProto&&) = default;
   MethodDescriptorProto& operator=(const MethodDescriptorProto&) = default;
   MethodDescriptorProto& operator=(MethodDescriptorProto&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -1904,7 +1907,7 @@
     NamePart(NamePart&&) = default;
     NamePart& operator=(const NamePart&) = default;
     NamePart& operator=(NamePart&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_name_part() {
@@ -1938,7 +1941,7 @@
   UninterpretedOption(UninterpretedOption&&) = default;
   UninterpretedOption& operator=(const UninterpretedOption&) = default;
   UninterpretedOption& operator=(UninterpretedOption&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::rs::google::protobuf::UninterpretedOption::NamePart >* mutable_name() {
@@ -1991,7 +1994,7 @@
     FeatureSetEditionDefault(FeatureSetEditionDefault&&) = default;
     FeatureSetEditionDefault& operator=(const FeatureSetEditionDefault&) = default;
     FeatureSetEditionDefault& operator=(FeatureSetEditionDefault&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     ::rs::google::protobuf::Edition* mutable_edition() {
@@ -2020,7 +2023,7 @@
   FeatureSetDefaults(FeatureSetDefaults&&) = default;
   FeatureSetDefaults& operator=(const FeatureSetDefaults&) = default;
   FeatureSetDefaults& operator=(FeatureSetDefaults&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::rs::google::protobuf::FeatureSetDefaults::FeatureSetEditionDefault >* mutable_defaults() {
@@ -2063,7 +2066,7 @@
     Annotation(Annotation&&) = default;
     Annotation& operator=(const Annotation&) = default;
     Annotation& operator=(Annotation&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::vector< int32_t >* mutable_path() {
@@ -2101,7 +2104,7 @@
   GeneratedCodeInfo(GeneratedCodeInfo&&) = default;
   GeneratedCodeInfo& operator=(const GeneratedCodeInfo&) = default;
   GeneratedCodeInfo& operator=(GeneratedCodeInfo&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::rs::google::protobuf::GeneratedCodeInfo::Annotation >* mutable_annotation() {
@@ -2144,7 +2147,7 @@
   Duration(Duration&&) = default;
   Duration& operator=(const Duration&) = default;
   Duration& operator=(Duration&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   int64_t* mutable_seconds() {
@@ -2190,7 +2193,7 @@
   SelectiveGapicGeneration(SelectiveGapicGeneration&&) = default;
   SelectiveGapicGeneration& operator=(const SelectiveGapicGeneration&) = default;
   SelectiveGapicGeneration& operator=(SelectiveGapicGeneration&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< std::string >* mutable_methods() {
@@ -2218,7 +2221,7 @@
   CommonLanguageSettings(CommonLanguageSettings&&) = default;
   CommonLanguageSettings& operator=(const CommonLanguageSettings&) = default;
   CommonLanguageSettings& operator=(CommonLanguageSettings&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_reference_docs_uri() {
@@ -2246,7 +2249,7 @@
   CppSettings(CppSettings&&) = default;
   CppSettings& operator=(const CppSettings&) = default;
   CppSettings& operator=(CppSettings&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::api::CommonLanguageSettings* mutable_common() {
@@ -2266,7 +2269,7 @@
     RenamedServicesEntry(RenamedServicesEntry&&) = default;
     RenamedServicesEntry& operator=(const RenamedServicesEntry&) = default;
     RenamedServicesEntry& operator=(RenamedServicesEntry&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_key() {
@@ -2291,7 +2294,7 @@
     RenamedResourcesEntry(RenamedResourcesEntry&&) = default;
     RenamedResourcesEntry& operator=(const RenamedResourcesEntry&) = default;
     RenamedResourcesEntry& operator=(RenamedResourcesEntry&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_key() {
@@ -2323,7 +2326,7 @@
   DotnetSettings(DotnetSettings&&) = default;
   DotnetSettings& operator=(const DotnetSettings&) = default;
   DotnetSettings& operator=(DotnetSettings&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::api::CommonLanguageSettings* mutable_common() {
@@ -2371,7 +2374,7 @@
     RenamedServicesEntry(RenamedServicesEntry&&) = default;
     RenamedServicesEntry& operator=(const RenamedServicesEntry&) = default;
     RenamedServicesEntry& operator=(RenamedServicesEntry&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_key() {
@@ -2395,7 +2398,7 @@
   GoSettings(GoSettings&&) = default;
   GoSettings& operator=(const GoSettings&) = default;
   GoSettings& operator=(GoSettings&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::api::CommonLanguageSettings* mutable_common() {
@@ -2420,7 +2423,7 @@
     ServiceClassNamesEntry(ServiceClassNamesEntry&&) = default;
     ServiceClassNamesEntry& operator=(const ServiceClassNamesEntry&) = default;
     ServiceClassNamesEntry& operator=(ServiceClassNamesEntry&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_key() {
@@ -2446,7 +2449,7 @@
   JavaSettings(JavaSettings&&) = default;
   JavaSettings& operator=(const JavaSettings&) = default;
   JavaSettings& operator=(JavaSettings&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_library_package() {
@@ -2473,7 +2476,7 @@
   NodeSettings(NodeSettings&&) = default;
   NodeSettings& operator=(const NodeSettings&) = default;
   NodeSettings& operator=(NodeSettings&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::api::CommonLanguageSettings* mutable_common() {
@@ -2490,7 +2493,7 @@
   PhpSettings(PhpSettings&&) = default;
   PhpSettings& operator=(const PhpSettings&) = default;
   PhpSettings& operator=(PhpSettings&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::api::CommonLanguageSettings* mutable_common() {
@@ -2512,7 +2515,7 @@
     ExperimentalFeatures(ExperimentalFeatures&&) = default;
     ExperimentalFeatures& operator=(const ExperimentalFeatures&) = default;
     ExperimentalFeatures& operator=(ExperimentalFeatures&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     bool* mutable_rest_async_io_enabled() {
@@ -2541,7 +2544,7 @@
   PythonSettings(PythonSettings&&) = default;
   PythonSettings& operator=(const PythonSettings&) = default;
   PythonSettings& operator=(PythonSettings&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::api::CommonLanguageSettings* mutable_common() {
@@ -2562,7 +2565,7 @@
   RubySettings(RubySettings&&) = default;
   RubySettings& operator=(const RubySettings&) = default;
   RubySettings& operator=(RubySettings&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::api::CommonLanguageSettings* mutable_common() {
@@ -2599,7 +2602,7 @@
   ClientLibrarySettings(ClientLibrarySettings&&) = default;
   ClientLibrarySettings& operator=(const ClientLibrarySettings&) = default;
   ClientLibrarySettings& operator=(ClientLibrarySettings&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_version() {
@@ -2679,7 +2682,7 @@
   Publishing(Publishing&&) = default;
   Publishing& operator=(const Publishing&) = default;
   Publishing& operator=(Publishing&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::rs::google::api::MethodSettings >* mutable_method_settings() {
@@ -2755,7 +2758,7 @@
     LongRunning(LongRunning&&) = default;
     LongRunning& operator=(const LongRunning&) = default;
     LongRunning& operator=(LongRunning&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     ::rs::google::protobuf::Duration* mutable_initial_poll_delay() {
@@ -2788,7 +2791,7 @@
   MethodSettings(MethodSettings&&) = default;
   MethodSettings& operator=(const MethodSettings&) = default;
   MethodSettings& operator=(MethodSettings&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_selector() {
@@ -2859,7 +2862,7 @@
   ResourceDescriptor(ResourceDescriptor&&) = default;
   ResourceDescriptor& operator=(const ResourceDescriptor&) = default;
   ResourceDescriptor& operator=(ResourceDescriptor&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_type() {
@@ -2911,7 +2914,7 @@
   ResourceReference(ResourceReference&&) = default;
   ResourceReference& operator=(const ResourceReference&) = default;
   ResourceReference& operator=(ResourceReference&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_type() {
@@ -2940,7 +2943,7 @@
   Timestamp(Timestamp&&) = default;
   Timestamp& operator=(const Timestamp&) = default;
   Timestamp& operator=(Timestamp&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   int64_t* mutable_seconds() {
@@ -3020,7 +3023,7 @@
   StatusAttributes(StatusAttributes&&) = default;
   StatusAttributes& operator=(const StatusAttributes&) = default;
   StatusAttributes& operator=(StatusAttributes&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::devtools::resultstore::v2::Status* mutable_status() {
@@ -3045,7 +3048,7 @@
   Property(Property&&) = default;
   Property& operator=(const Property&) = default;
   Property& operator=(Property&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_key() {
@@ -3070,7 +3073,7 @@
   Timing(Timing&&) = default;
   Timing& operator=(const Timing&) = default;
   Timing& operator=(Timing&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::protobuf::Timestamp* mutable_start_time() {
@@ -3096,7 +3099,7 @@
     Id(Id&&) = default;
     Id& operator=(const Id&) = default;
     Id& operator=(Id&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_target_id() {
@@ -3131,7 +3134,7 @@
   Dependency(Dependency&&) = default;
   Dependency& operator=(const Dependency&) = default;
   Dependency& operator=(Dependency&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_target() {
@@ -3178,7 +3181,7 @@
   LineCoverage(LineCoverage&&) = default;
   LineCoverage& operator=(const LineCoverage&) = default;
   LineCoverage& operator=(LineCoverage&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_instrumented_lines() {
@@ -3207,7 +3210,7 @@
   BranchCoverage(BranchCoverage&&) = default;
   BranchCoverage& operator=(const BranchCoverage&) = default;
   BranchCoverage& operator=(BranchCoverage&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_branch_present() {
@@ -3245,7 +3248,7 @@
   FileCoverage(FileCoverage&&) = default;
   FileCoverage& operator=(const FileCoverage&) = default;
   FileCoverage& operator=(FileCoverage&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_path() {
@@ -3271,7 +3274,7 @@
   ActionCoverage(ActionCoverage&&) = default;
   ActionCoverage& operator=(const ActionCoverage&) = default;
   ActionCoverage& operator=(ActionCoverage&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::rs::google::devtools::resultstore::v2::FileCoverage >* mutable_file_coverages() {
@@ -3289,7 +3292,7 @@
   AggregateCoverage(AggregateCoverage&&) = default;
   AggregateCoverage& operator=(const AggregateCoverage&) = default;
   AggregateCoverage& operator=(AggregateCoverage&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< ::rs::google::devtools::resultstore::v2::FileCoverage >* mutable_file_coverages() {
@@ -3313,7 +3316,7 @@
   DoubleValue(DoubleValue&&) = default;
   DoubleValue& operator=(const DoubleValue&) = default;
   DoubleValue& operator=(DoubleValue&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   double* mutable_value() {
@@ -3331,7 +3334,7 @@
   FloatValue(FloatValue&&) = default;
   FloatValue& operator=(const FloatValue&) = default;
   FloatValue& operator=(FloatValue&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   float* mutable_value() {
@@ -3349,7 +3352,7 @@
   Int64Value(Int64Value&&) = default;
   Int64Value& operator=(const Int64Value&) = default;
   Int64Value& operator=(Int64Value&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   int64_t* mutable_value() {
@@ -3367,7 +3370,7 @@
   UInt64Value(UInt64Value&&) = default;
   UInt64Value& operator=(const UInt64Value&) = default;
   UInt64Value& operator=(UInt64Value&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   uint64_t* mutable_value() {
@@ -3385,7 +3388,7 @@
   Int32Value(Int32Value&&) = default;
   Int32Value& operator=(const Int32Value&) = default;
   Int32Value& operator=(Int32Value&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   int32_t* mutable_value() {
@@ -3403,7 +3406,7 @@
   UInt32Value(UInt32Value&&) = default;
   UInt32Value& operator=(const UInt32Value&) = default;
   UInt32Value& operator=(UInt32Value&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   uint32_t* mutable_value() {
@@ -3421,7 +3424,7 @@
   BoolValue(BoolValue&&) = default;
   BoolValue& operator=(const BoolValue&) = default;
   BoolValue& operator=(BoolValue&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   bool* mutable_value() {
@@ -3439,7 +3442,7 @@
   StringValue(StringValue&&) = default;
   StringValue& operator=(const StringValue&) = default;
   StringValue& operator=(StringValue&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_value() {
@@ -3457,7 +3460,7 @@
   BytesValue(BytesValue&&) = default;
   BytesValue& operator=(const BytesValue&) = default;
   BytesValue& operator=(BytesValue&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_value() {
@@ -3485,7 +3488,7 @@
   ArchiveEntry(ArchiveEntry&&) = default;
   ArchiveEntry& operator=(const ArchiveEntry&) = default;
   ArchiveEntry& operator=(ArchiveEntry&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_path() {
@@ -3537,7 +3540,7 @@
   File(File&&) = default;
   File& operator=(const File&) = default;
   File& operator=(File&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_uid() {
@@ -3620,7 +3623,7 @@
   FileProcessingErrors(FileProcessingErrors&&) = default;
   FileProcessingErrors& operator=(const FileProcessingErrors&) = default;
   FileProcessingErrors& operator=(FileProcessingErrors&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_file_uid() {
@@ -3645,7 +3648,7 @@
   FileProcessingError(FileProcessingError&&) = default;
   FileProcessingError& operator=(const FileProcessingError&) = default;
   FileProcessingError& operator=(FileProcessingError&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::devtools::resultstore::v2::FileProcessingErrorType* mutable_type() {
@@ -3688,7 +3691,7 @@
   TestSuite(TestSuite&&) = default;
   TestSuite& operator=(const TestSuite&) = default;
   TestSuite& operator=(TestSuite&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_suite_name() {
@@ -3763,7 +3766,7 @@
   TestCase(TestCase&&) = default;
   TestCase& operator=(const TestCase&) = default;
   TestCase& operator=(TestCase&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_case_name() {
@@ -3827,7 +3830,7 @@
   Test(Test&&) = default;
   Test& operator=(const Test&) = default;
   Test& operator=(Test&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::devtools::resultstore::v2::TestCase* mutable_test_case() {
@@ -3856,7 +3859,7 @@
   TestFailure(TestFailure&&) = default;
   TestFailure& operator=(const TestFailure&) = default;
   TestFailure& operator=(TestFailure&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_failure_message() {
@@ -3900,7 +3903,7 @@
   TestError(TestError&&) = default;
   TestError& operator=(const TestError&) = default;
   TestError& operator=(TestError&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_error_message() {
@@ -3959,7 +3962,7 @@
   InputFileInfo(InputFileInfo&&) = default;
   InputFileInfo& operator=(const InputFileInfo&) = default;
   InputFileInfo& operator=(InputFileInfo&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   int64_t* mutable_count() {
@@ -4003,7 +4006,7 @@
   ActionAttributes(ActionAttributes&&) = default;
   ActionAttributes& operator=(const ActionAttributes&) = default;
   ActionAttributes& operator=(ActionAttributes&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::devtools::resultstore::v2::ExecutionStrategy* mutable_execution_strategy() {
@@ -4039,7 +4042,7 @@
   BuildAction(BuildAction&&) = default;
   BuildAction& operator=(const BuildAction&) = default;
   BuildAction& operator=(BuildAction&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_type() {
@@ -4067,7 +4070,7 @@
   LocalTestTiming(LocalTestTiming&&) = default;
   LocalTestTiming& operator=(const LocalTestTiming&) = default;
   LocalTestTiming& operator=(LocalTestTiming&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::protobuf::Duration* mutable_test_process_duration() {
@@ -4086,7 +4089,7 @@
   RemoteTestTiming(RemoteTestTiming&&) = default;
   RemoteTestTiming& operator=(const RemoteTestTiming&) = default;
   RemoteTestTiming& operator=(RemoteTestTiming&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::protobuf::Duration* mutable_local_analysis_duration() {
@@ -4116,7 +4119,7 @@
   TestTiming(TestTiming&&) = default;
   TestTiming& operator=(const TestTiming&) = default;
   TestTiming& operator=(TestTiming&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::devtools::resultstore::v2::LocalTestTiming* mutable_local() {
@@ -4162,7 +4165,7 @@
   TestAction(TestAction&&) = default;
   TestAction& operator=(const TestAction&) = default;
   TestAction& operator=(TestAction&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::devtools::resultstore::v2::TestTiming* mutable_test_timing() {
@@ -4215,7 +4218,7 @@
     Id(Id&&) = default;
     Id& operator=(const Id&) = default;
     Id& operator=(Id&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_invocation_id() {
@@ -4271,7 +4274,7 @@
   Action(Action&&) = default;
   Action& operator=(const Action&) = default;
   Action& operator=(Action&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -4351,7 +4354,7 @@
   RemoteTestAttemptTiming(RemoteTestAttemptTiming&&) = default;
   RemoteTestAttemptTiming& operator=(const RemoteTestAttemptTiming&) = default;
   RemoteTestAttemptTiming& operator=(RemoteTestAttemptTiming&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::protobuf::Duration* mutable_queue_duration() {
@@ -4384,7 +4387,7 @@
   TestWarning(TestWarning&&) = default;
   TestWarning& operator=(const TestWarning&) = default;
   TestWarning& operator=(TestWarning&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_warning_message() {
@@ -4410,7 +4413,7 @@
   ConfigurationAttributes(ConfigurationAttributes&&) = default;
   ConfigurationAttributes& operator=(const ConfigurationAttributes&) = default;
   ConfigurationAttributes& operator=(ConfigurationAttributes&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_cpu() {
@@ -4431,7 +4434,7 @@
     Id(Id&&) = default;
     Id& operator=(const Id&) = default;
     Id& operator=(Id&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_invocation_id() {
@@ -4463,7 +4466,7 @@
   Configuration(Configuration&&) = default;
   Configuration& operator=(const Configuration&) = default;
   Configuration& operator=(Configuration&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -4515,7 +4518,7 @@
   ConfiguredTestAttributes(ConfiguredTestAttributes&&) = default;
   ConfiguredTestAttributes& operator=(const ConfiguredTestAttributes&) = default;
   ConfiguredTestAttributes& operator=(ConfiguredTestAttributes&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   int32_t* mutable_total_run_count() {
@@ -4547,7 +4550,7 @@
     Id(Id&&) = default;
     Id& operator=(const Id&) = default;
     Id& operator=(Id&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_invocation_id() {
@@ -4586,7 +4589,7 @@
   ConfiguredTarget(ConfiguredTarget&&) = default;
   ConfiguredTarget& operator=(const ConfiguredTarget&) = default;
   ConfiguredTarget& operator=(ConfiguredTarget&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -4641,7 +4644,7 @@
     Id(Id&&) = default;
     Id& operator=(const Id&) = default;
     Id& operator=(Id&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_invocation_id() {
@@ -4669,7 +4672,7 @@
   FileSet(FileSet&&) = default;
   FileSet& operator=(const FileSet&) = default;
   FileSet& operator=(FileSet&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -4712,7 +4715,7 @@
   LineCoverageSummary(LineCoverageSummary&&) = default;
   LineCoverageSummary& operator=(const LineCoverageSummary&) = default;
   LineCoverageSummary& operator=(LineCoverageSummary&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   int32_t* mutable_instrumented_line_count() {
@@ -4739,7 +4742,7 @@
   BranchCoverageSummary(BranchCoverageSummary&&) = default;
   BranchCoverageSummary& operator=(const BranchCoverageSummary&) = default;
   BranchCoverageSummary& operator=(BranchCoverageSummary&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   int32_t* mutable_total_branch_count() {
@@ -4771,7 +4774,7 @@
   LanguageCoverageSummary(LanguageCoverageSummary&&) = default;
   LanguageCoverageSummary& operator=(const LanguageCoverageSummary&) = default;
   LanguageCoverageSummary& operator=(LanguageCoverageSummary&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::devtools::resultstore::v2::Language* mutable_language() {
@@ -4815,7 +4818,7 @@
   InvocationAttributes(InvocationAttributes&&) = default;
   InvocationAttributes& operator=(const InvocationAttributes&) = default;
   InvocationAttributes& operator=(InvocationAttributes&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_project_id() {
@@ -4857,7 +4860,7 @@
   WorkspaceContext(WorkspaceContext&&) = default;
   WorkspaceContext& operator=(const WorkspaceContext&) = default;
   WorkspaceContext& operator=(WorkspaceContext&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
 };  // struct WorkspaceContext
@@ -4878,7 +4881,7 @@
   WorkspaceInfo(WorkspaceInfo&&) = default;
   WorkspaceInfo& operator=(const WorkspaceInfo&) = default;
   WorkspaceInfo& operator=(WorkspaceInfo&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::devtools::resultstore::v2::WorkspaceContext* mutable_workspace_context() {
@@ -4916,7 +4919,7 @@
     Id(Id&&) = default;
     Id& operator=(const Id&) = default;
     Id& operator=(Id&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_invocation_id() {
@@ -4953,7 +4956,7 @@
   Invocation(Invocation&&) = default;
   Invocation& operator=(const Invocation&) = default;
   Invocation& operator=(Invocation&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -5021,7 +5024,7 @@
   CommandLine(CommandLine&&) = default;
   CommandLine& operator=(const CommandLine&) = default;
   CommandLine& operator=(CommandLine&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_label() {
@@ -5057,7 +5060,7 @@
   InvocationContext(InvocationContext&&) = default;
   InvocationContext& operator=(const InvocationContext&) = default;
   InvocationContext& operator=(InvocationContext&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_display_name() {
@@ -5110,7 +5113,7 @@
   TargetAttributes(TargetAttributes&&) = default;
   TargetAttributes& operator=(const TargetAttributes&) = default;
   TargetAttributes& operator=(TargetAttributes&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::devtools::resultstore::v2::TargetType* mutable_type() {
@@ -5139,7 +5142,7 @@
   TestAttributes(TestAttributes&&) = default;
   TestAttributes& operator=(const TestAttributes&) = default;
   TestAttributes& operator=(TestAttributes&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::devtools::resultstore::v2::TestSize* mutable_size() {
@@ -5160,7 +5163,7 @@
     Id(Id&&) = default;
     Id& operator=(const Id&) = default;
     Id& operator=(Id&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_invocation_id() {
@@ -5198,7 +5201,7 @@
   Target(Target&&) = default;
   Target& operator=(const Target&) = default;
   Target& operator=(Target&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -5263,7 +5266,7 @@
   UploadMetadata(UploadMetadata&&) = default;
   UploadMetadata& operator=(const UploadMetadata&) = default;
   UploadMetadata& operator=(UploadMetadata&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -5294,7 +5297,7 @@
   Empty(Empty&&) = default;
   Empty& operator=(const Empty&) = default;
   Empty& operator=(Empty&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
 };  // struct Empty
@@ -5311,7 +5314,7 @@
   FieldMask(FieldMask&&) = default;
   FieldMask& operator=(const FieldMask&) = default;
   FieldMask& operator=(FieldMask&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::vector< std::string >* mutable_paths() {
@@ -5348,7 +5351,7 @@
   CreateInvocationRequest(CreateInvocationRequest&&) = default;
   CreateInvocationRequest& operator=(const CreateInvocationRequest&) = default;
   CreateInvocationRequest& operator=(CreateInvocationRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_request_id() {
@@ -5398,7 +5401,7 @@
   UpdateInvocationRequest(UpdateInvocationRequest&&) = default;
   UpdateInvocationRequest& operator=(const UpdateInvocationRequest&) = default;
   UpdateInvocationRequest& operator=(UpdateInvocationRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::devtools::resultstore::v2::Invocation* mutable_invocation() {
@@ -5430,7 +5433,7 @@
   MergeInvocationRequest(MergeInvocationRequest&&) = default;
   MergeInvocationRequest& operator=(const MergeInvocationRequest&) = default;
   MergeInvocationRequest& operator=(MergeInvocationRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_request_id() {
@@ -5463,7 +5466,7 @@
   TouchInvocationRequest(TouchInvocationRequest&&) = default;
   TouchInvocationRequest& operator=(const TouchInvocationRequest&) = default;
   TouchInvocationRequest& operator=(TouchInvocationRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -5488,7 +5491,7 @@
   TouchInvocationResponse(TouchInvocationResponse&&) = default;
   TouchInvocationResponse& operator=(const TouchInvocationResponse&) = default;
   TouchInvocationResponse& operator=(TouchInvocationResponse&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -5510,7 +5513,7 @@
   DeleteInvocationRequest(DeleteInvocationRequest&&) = default;
   DeleteInvocationRequest& operator=(const DeleteInvocationRequest&) = default;
   DeleteInvocationRequest& operator=(DeleteInvocationRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -5530,7 +5533,7 @@
   FinalizeInvocationRequest(FinalizeInvocationRequest&&) = default;
   FinalizeInvocationRequest& operator=(const FinalizeInvocationRequest&) = default;
   FinalizeInvocationRequest& operator=(FinalizeInvocationRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -5555,7 +5558,7 @@
   FinalizeInvocationResponse(FinalizeInvocationResponse&&) = default;
   FinalizeInvocationResponse& operator=(const FinalizeInvocationResponse&) = default;
   FinalizeInvocationResponse& operator=(FinalizeInvocationResponse&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -5585,7 +5588,7 @@
   CreateTargetRequest(CreateTargetRequest&&) = default;
   CreateTargetRequest& operator=(const CreateTargetRequest&) = default;
   CreateTargetRequest& operator=(CreateTargetRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_request_id() {
@@ -5628,7 +5631,7 @@
   UpdateTargetRequest(UpdateTargetRequest&&) = default;
   UpdateTargetRequest& operator=(const UpdateTargetRequest&) = default;
   UpdateTargetRequest& operator=(UpdateTargetRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::devtools::resultstore::v2::Target* mutable_target() {
@@ -5667,7 +5670,7 @@
   MergeTargetRequest(MergeTargetRequest&&) = default;
   MergeTargetRequest& operator=(const MergeTargetRequest&) = default;
   MergeTargetRequest& operator=(MergeTargetRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_request_id() {
@@ -5705,7 +5708,7 @@
   FinalizeTargetRequest(FinalizeTargetRequest&&) = default;
   FinalizeTargetRequest& operator=(const FinalizeTargetRequest&) = default;
   FinalizeTargetRequest& operator=(FinalizeTargetRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -5730,7 +5733,7 @@
   FinalizeTargetResponse(FinalizeTargetResponse&&) = default;
   FinalizeTargetResponse& operator=(const FinalizeTargetResponse&) = default;
   FinalizeTargetResponse& operator=(FinalizeTargetResponse&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -5760,7 +5763,7 @@
   CreateConfiguredTargetRequest(CreateConfiguredTargetRequest&&) = default;
   CreateConfiguredTargetRequest& operator=(const CreateConfiguredTargetRequest&) = default;
   CreateConfiguredTargetRequest& operator=(CreateConfiguredTargetRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_request_id() {
@@ -5803,7 +5806,7 @@
   UpdateConfiguredTargetRequest(UpdateConfiguredTargetRequest&&) = default;
   UpdateConfiguredTargetRequest& operator=(const UpdateConfiguredTargetRequest&) = default;
   UpdateConfiguredTargetRequest& operator=(UpdateConfiguredTargetRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::devtools::resultstore::v2::ConfiguredTarget* mutable_configured_target() {
@@ -5842,7 +5845,7 @@
   MergeConfiguredTargetRequest(MergeConfiguredTargetRequest&&) = default;
   MergeConfiguredTargetRequest& operator=(const MergeConfiguredTargetRequest&) = default;
   MergeConfiguredTargetRequest& operator=(MergeConfiguredTargetRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_request_id() {
@@ -5880,7 +5883,7 @@
   FinalizeConfiguredTargetRequest(FinalizeConfiguredTargetRequest&&) = default;
   FinalizeConfiguredTargetRequest& operator=(const FinalizeConfiguredTargetRequest&) = default;
   FinalizeConfiguredTargetRequest& operator=(FinalizeConfiguredTargetRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -5905,7 +5908,7 @@
   FinalizeConfiguredTargetResponse(FinalizeConfiguredTargetResponse&&) = default;
   FinalizeConfiguredTargetResponse& operator=(const FinalizeConfiguredTargetResponse&) = default;
   FinalizeConfiguredTargetResponse& operator=(FinalizeConfiguredTargetResponse&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
@@ -5935,7 +5938,7 @@
   CreateActionRequest(CreateActionRequest&&) = default;
   CreateActionRequest& operator=(const CreateActionRequest&) = default;
   CreateActionRequest& operator=(CreateActionRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_request_id() {
@@ -5978,7 +5981,7 @@
   UpdateActionRequest(UpdateActionRequest&&) = default;
   UpdateActionRequest& operator=(const UpdateActionRequest&) = default;
   UpdateActionRequest& operator=(UpdateActionRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::devtools::resultstore::v2::Action* mutable_action() {
@@ -6017,7 +6020,7 @@
   MergeActionRequest(MergeActionRequest&&) = default;
   MergeActionRequest& operator=(const MergeActionRequest&) = default;
   MergeActionRequest& operator=(MergeActionRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_request_id() {
@@ -6061,7 +6064,7 @@
   CreateConfigurationRequest(CreateConfigurationRequest&&) = default;
   CreateConfigurationRequest& operator=(const CreateConfigurationRequest&) = default;
   CreateConfigurationRequest& operator=(CreateConfigurationRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_request_id() {
@@ -6104,7 +6107,7 @@
   UpdateConfigurationRequest(UpdateConfigurationRequest&&) = default;
   UpdateConfigurationRequest& operator=(const UpdateConfigurationRequest&) = default;
   UpdateConfigurationRequest& operator=(UpdateConfigurationRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::devtools::resultstore::v2::Configuration* mutable_configuration() {
@@ -6143,7 +6146,7 @@
   CreateFileSetRequest(CreateFileSetRequest&&) = default;
   CreateFileSetRequest& operator=(const CreateFileSetRequest&) = default;
   CreateFileSetRequest& operator=(CreateFileSetRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_request_id() {
@@ -6186,7 +6189,7 @@
   UpdateFileSetRequest(UpdateFileSetRequest&&) = default;
   UpdateFileSetRequest& operator=(const UpdateFileSetRequest&) = default;
   UpdateFileSetRequest& operator=(UpdateFileSetRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::devtools::resultstore::v2::FileSet* mutable_file_set() {
@@ -6225,7 +6228,7 @@
   MergeFileSetRequest(MergeFileSetRequest&&) = default;
   MergeFileSetRequest& operator=(const MergeFileSetRequest&) = default;
   MergeFileSetRequest& operator=(MergeFileSetRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_request_id() {
@@ -6271,7 +6274,7 @@
   UploadBatchRequest(UploadBatchRequest&&) = default;
   UploadBatchRequest& operator=(const UploadBatchRequest&) = default;
   UploadBatchRequest& operator=(UploadBatchRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_parent() {
@@ -6311,7 +6314,7 @@
   UploadBatchResponse(UploadBatchResponse&&) = default;
   UploadBatchResponse& operator=(const UploadBatchResponse&) = default;
   UploadBatchResponse& operator=(UploadBatchResponse&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
 };  // struct UploadBatchResponse
@@ -6339,7 +6342,7 @@
     Id(Id&&) = default;
     Id& operator=(const Id&) = default;
     Id& operator=(Id&&) = default;
-    void SerializeToOstream(std::ostream* output__) const;
+    void SerializeToOstream(OutputStream* output__) const;
     size_t ByteSizeLong() const;
     void Clear();
     std::string* mutable_target_id() {
@@ -6389,7 +6392,7 @@
   UploadRequest(UploadRequest&&) = default;
   UploadRequest& operator=(const UploadRequest&) = default;
   UploadRequest& operator=(UploadRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   ::rs::google::devtools::resultstore::v2::UploadRequest::Id* mutable_id() {
@@ -6446,7 +6449,7 @@
   GetInvocationUploadMetadataRequest(GetInvocationUploadMetadataRequest&&) = default;
   GetInvocationUploadMetadataRequest& operator=(const GetInvocationUploadMetadataRequest&) = default;
   GetInvocationUploadMetadataRequest& operator=(GetInvocationUploadMetadataRequest&&) = default;
-  void SerializeToOstream(std::ostream* output__) const;
+  void SerializeToOstream(OutputStream* output__) const;
   size_t ByteSizeLong() const;
   void Clear();
   std::string* mutable_name() {
diff --git a/src/resultstore_streamer.cc b/src/resultstore_streamer.cc
index f1512d7..ae2b8fc 100644
--- a/src/resultstore_streamer.cc
+++ b/src/resultstore_streamer.cc
@@ -15,7 +15,6 @@
 #include "resultstore_streamer.h"
 
 #include <cstdarg>
-#include <ostream>
 #include <numeric>
 
 #include "graph.h"
@@ -24,12 +23,15 @@
 #include "util.h"
 #include "version.h"
 
+#include "output_stream.h"
+
 // On Windows, a system header #defines OPTIONAL, which conflicts with
-// an enum value of the same name in resultstore.proto.
+// an enum value of the same name in resultstore_upload.proto.
 // Un-define it as a workaround.
 #ifdef OPTIONAL
 #undef OPTIONAL
 #endif
+
 #include "resultstore.pb.h"
 
 namespace rspb = ::rs::google::devtools::resultstore::v2;
@@ -121,17 +123,12 @@
 
 ResultStoreStreamer::ResultStoreStreamer(
     const std::vector<std::string>& ninja_command,
-    const std::string& config_string,
-    const BuildMetadataMap& metadata,
-    const std::string& build_id,
-    int64_t start_time_millis,
-    std::ostream* out) :
-  ninja_command_(ninja_command),
-  config_string_(config_string),
-  metadata_(metadata),  // keep extra copy
-  start_time_millis_(start_time_millis),
-  initial_invocation_(std::make_unique<rspb::Invocation>()),
-  out_(out) {
+    const std::string& config_string, const BuildMetadataMap& metadata,
+    const std::string& build_id, int64_t start_time_millis, OutputStream* out)
+    : ninja_command_(ninja_command), config_string_(config_string),
+      metadata_(metadata),  // keep extra copy
+      start_time_millis_(start_time_millis),
+      initial_invocation_(std::make_unique<rspb::Invocation>()), out_(out) {
   initialize_invocation(initial_invocation_.get(), ninja_command,
                         build_id, start_time_millis, metadata);
 }
diff --git a/src/resultstore_streamer.h b/src/resultstore_streamer.h
index 0dfb0d5..17de7fa 100644
--- a/src/resultstore_streamer.h
+++ b/src/resultstore_streamer.h
@@ -15,15 +15,15 @@
 #ifndef NINJA_RESULTSTORE_STREAMER_H_
 #define NINJA_RESULTSTORE_STREAMER_H_
 
-#include "status.h"
-
-#include <iosfwd>
 #include <map>
 #include <memory>
 #include <string>
 #include <vector>
 
 #include "bes_types.h"
+#include "status.h"
+
+struct OutputStream;
 
 namespace rs {
 namespace google {
@@ -48,11 +48,10 @@
   /// start_time_millis: start time of build in ms.
   /// out: output stream to write build events (unbuffered).
   ResultStoreStreamer(const std::vector<std::string>& ninja_command,
-                     const std::string& config_string,
-                     const BuildMetadataMap& metadata,
-                     const std::string& build_id,
-                     int64_t start_time_millis,
-                     std::ostream* out);
+                      const std::string& config_string,
+                      const BuildMetadataMap& metadata,
+                      const std::string& build_id, int64_t start_time_millis,
+                      OutputStream* out);
   virtual ~ResultStoreStreamer();
 
   void EdgeAddedToPlan(const Edge* edge) override;
@@ -92,7 +91,7 @@
   BuildMetadataMap metadata_;
 
   /// Start time of ninja invocation.
-  int64_t start_time_millis_;
+  int64_t start_time_millis_ = 0;
 
   typedef ::rs::google::devtools::resultstore::v2::Invocation Invocation;
   /// Initial invocation parameters.
@@ -100,7 +99,7 @@
 
   // Output stream (should be configured un-buffered)
   // Not owned, so the stream object should outlive this object.
-  std::ostream* out_;
+  OutputStream* out_ = nullptr;
 };
 
 #endif // NINJA_RESULTSTORE_STREAMER_H_