• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <limits>
2 
3 #include "google/protobuf/message_lite.h"
4 #include "rust/cpp_kernel/serialized_data.h"
5 
6 extern "C" {
7 
proto2_rust_Message_delete(google::protobuf::MessageLite * m)8 void proto2_rust_Message_delete(google::protobuf::MessageLite* m) { delete m; }
9 
proto2_rust_Message_clear(google::protobuf::MessageLite * m)10 void proto2_rust_Message_clear(google::protobuf::MessageLite* m) { m->Clear(); }
11 
proto2_rust_Message_parse(google::protobuf::MessageLite * m,google::protobuf::rust::SerializedData input)12 bool proto2_rust_Message_parse(google::protobuf::MessageLite* m,
13                                google::protobuf::rust::SerializedData input) {
14   if (input.len > std::numeric_limits<int>::max()) {
15     return false;
16   }
17   return m->ParseFromArray(input.data, static_cast<int>(input.len));
18 }
19 
proto2_rust_Message_serialize(const google::protobuf::MessageLite * m,google::protobuf::rust::SerializedData * output)20 bool proto2_rust_Message_serialize(const google::protobuf::MessageLite* m,
21                                    google::protobuf::rust::SerializedData* output) {
22   return google::protobuf::rust::SerializeMsg(m, output);
23 }
24 
proto2_rust_Message_copy_from(google::protobuf::MessageLite * dst,const google::protobuf::MessageLite & src)25 void proto2_rust_Message_copy_from(google::protobuf::MessageLite* dst,
26                                    const google::protobuf::MessageLite& src) {
27   dst->Clear();
28   dst->CheckTypeAndMergeFrom(src);
29 }
30 
proto2_rust_Message_merge_from(google::protobuf::MessageLite * dst,const google::protobuf::MessageLite & src)31 void proto2_rust_Message_merge_from(google::protobuf::MessageLite* dst,
32                                     const google::protobuf::MessageLite& src) {
33   dst->CheckTypeAndMergeFrom(src);
34 }
35 
36 }  // extern "C"
37