proto, runtime/protoiface: add support for fast-path marshaling
Allow message implementations to provide optimized versions of standard
operations. Generated messages now include a ProtoReflectMethods method,
returning a protoiface.Methods struct containing pointers to assorted
optional functions.
The Methods struct also includes a Flags field indicating support for
optional features such as deterministic marshaling.
Implementation of the fast paths (and tests) will come in later CLs.
Change-Id: Idd1beed0ecf43ec5e5e7b8da2ee1e08d3ce32213
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/170340
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/internal/testprotos/legacy/legacy.pb.go b/internal/testprotos/legacy/legacy.pb.go
index d394dc2..ab5ab0e 100644
--- a/internal/testprotos/legacy/legacy.pb.go
+++ b/internal/testprotos/legacy/legacy.pb.go
@@ -18,6 +18,7 @@
proto3_v1_21 "github.com/golang/protobuf/v2/internal/testprotos/legacy/proto3.v1.2.1-20181126-8d0c54c1"
protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
protoregistry "github.com/golang/protobuf/v2/reflect/protoregistry"
+ protoiface "github.com/golang/protobuf/v2/runtime/protoiface"
protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
sync "sync"
)
@@ -56,6 +57,10 @@
return xxx_File_legacy_legacy_proto_messageTypes[0].MessageOf(x)
}
+func (m *Legacy) XXX_Methods() *protoiface.Methods {
+ return xxx_File_legacy_legacy_proto_messageTypes[0].Methods()
+}
+
// Deprecated: Use Legacy.ProtoReflect.Type instead.
func (*Legacy) Descriptor() ([]byte, []int) {
return xxx_File_legacy_legacy_proto_rawDescGZIP(), []int{0}