• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "rust/cpp_kernel/compare.h"
2 
3 #include <string>
4 
5 #include "google/protobuf/io/zero_copy_stream_impl_lite.h"
6 #include "google/protobuf/message_lite.h"
7 
SerializeDeterministically(const google::protobuf::MessageLite & m)8 static std::string SerializeDeterministically(const google::protobuf::MessageLite& m) {
9   std::string serialized;
10   {
11     google::protobuf::io::StringOutputStream output_stream(&serialized);
12     google::protobuf::io::CodedOutputStream coded_stream(&output_stream);
13     coded_stream.SetSerializationDeterministic(true);
14     m.SerializePartialToCodedStream(&coded_stream);
15   }
16   return serialized;
17 }
18 
19 extern "C" {
20 
proto2_rust_messagelite_equals(const google::protobuf::MessageLite * msg1,const google::protobuf::MessageLite * msg2)21 bool proto2_rust_messagelite_equals(const google::protobuf::MessageLite* msg1,
22                                     const google::protobuf::MessageLite* msg2) {
23   return SerializeDeterministically(*msg1) == SerializeDeterministically(*msg2);
24 }
25 
26 }  // extern "C"
27