gatus/vendor/google.golang.org/protobuf/internal/impl/codec_tables.go

558 lines
16 KiB
Go
Raw Normal View History

2020-12-25 09:02:44 +01:00
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package impl
import (
"fmt"
"reflect"
"google.golang.org/protobuf/encoding/protowire"
"google.golang.org/protobuf/internal/strs"
"google.golang.org/protobuf/reflect/protoreflect"
2020-12-25 09:02:44 +01:00
)
// pointerCoderFuncs is a set of pointer encoding functions.
type pointerCoderFuncs struct {
mi *MessageInfo
size func(p pointer, f *coderFieldInfo, opts marshalOptions) int
marshal func(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error)
unmarshal func(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (unmarshalOutput, error)
isInit func(p pointer, f *coderFieldInfo) error
merge func(dst, src pointer, f *coderFieldInfo, opts mergeOptions)
}
// valueCoderFuncs is a set of protoreflect.Value encoding functions.
type valueCoderFuncs struct {
size func(v protoreflect.Value, tagsize int, opts marshalOptions) int
marshal func(b []byte, v protoreflect.Value, wiretag uint64, opts marshalOptions) ([]byte, error)
unmarshal func(b []byte, v protoreflect.Value, num protowire.Number, wtyp protowire.Type, opts unmarshalOptions) (protoreflect.Value, unmarshalOutput, error)
isInit func(v protoreflect.Value) error
merge func(dst, src protoreflect.Value, opts mergeOptions) protoreflect.Value
2020-12-25 09:02:44 +01:00
}
// fieldCoder returns pointer functions for a field, used for operating on
// struct fields.
func fieldCoder(fd protoreflect.FieldDescriptor, ft reflect.Type) (*MessageInfo, pointerCoderFuncs) {
2020-12-25 09:02:44 +01:00
switch {
case fd.IsMap():
return encoderFuncsForMap(fd, ft)
case fd.Cardinality() == protoreflect.Repeated && !fd.IsPacked():
2020-12-25 09:02:44 +01:00
// Repeated fields (not packed).
if ft.Kind() != reflect.Slice {
break
}
ft := ft.Elem()
switch fd.Kind() {
case protoreflect.BoolKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Bool {
return nil, coderBoolSlice
}
case protoreflect.EnumKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int32 {
return nil, coderEnumSlice
}
case protoreflect.Int32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int32 {
return nil, coderInt32Slice
}
case protoreflect.Sint32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int32 {
return nil, coderSint32Slice
}
case protoreflect.Uint32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Uint32 {
return nil, coderUint32Slice
}
case protoreflect.Int64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int64 {
return nil, coderInt64Slice
}
case protoreflect.Sint64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int64 {
return nil, coderSint64Slice
}
case protoreflect.Uint64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Uint64 {
return nil, coderUint64Slice
}
case protoreflect.Sfixed32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int32 {
return nil, coderSfixed32Slice
}
case protoreflect.Fixed32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Uint32 {
return nil, coderFixed32Slice
}
case protoreflect.FloatKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Float32 {
return nil, coderFloatSlice
}
case protoreflect.Sfixed64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int64 {
return nil, coderSfixed64Slice
}
case protoreflect.Fixed64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Uint64 {
return nil, coderFixed64Slice
}
case protoreflect.DoubleKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Float64 {
return nil, coderDoubleSlice
}
case protoreflect.StringKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.String && strs.EnforceUTF8(fd) {
return nil, coderStringSliceValidateUTF8
}
if ft.Kind() == reflect.String {
return nil, coderStringSlice
}
if ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8 && strs.EnforceUTF8(fd) {
return nil, coderBytesSliceValidateUTF8
}
if ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8 {
return nil, coderBytesSlice
}
case protoreflect.BytesKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.String {
return nil, coderStringSlice
}
if ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8 {
return nil, coderBytesSlice
}
case protoreflect.MessageKind:
2020-12-25 09:02:44 +01:00
return getMessageInfo(ft), makeMessageSliceFieldCoder(fd, ft)
case protoreflect.GroupKind:
2020-12-25 09:02:44 +01:00
return getMessageInfo(ft), makeGroupSliceFieldCoder(fd, ft)
}
case fd.Cardinality() == protoreflect.Repeated && fd.IsPacked():
2020-12-25 09:02:44 +01:00
// Packed repeated fields.
//
// Only repeated fields of primitive numeric types
// (Varint, Fixed32, or Fixed64 wire type) can be packed.
if ft.Kind() != reflect.Slice {
break
}
ft := ft.Elem()
switch fd.Kind() {
case protoreflect.BoolKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Bool {
return nil, coderBoolPackedSlice
}
case protoreflect.EnumKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int32 {
return nil, coderEnumPackedSlice
}
case protoreflect.Int32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int32 {
return nil, coderInt32PackedSlice
}
case protoreflect.Sint32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int32 {
return nil, coderSint32PackedSlice
}
case protoreflect.Uint32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Uint32 {
return nil, coderUint32PackedSlice
}
case protoreflect.Int64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int64 {
return nil, coderInt64PackedSlice
}
case protoreflect.Sint64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int64 {
return nil, coderSint64PackedSlice
}
case protoreflect.Uint64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Uint64 {
return nil, coderUint64PackedSlice
}
case protoreflect.Sfixed32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int32 {
return nil, coderSfixed32PackedSlice
}
case protoreflect.Fixed32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Uint32 {
return nil, coderFixed32PackedSlice
}
case protoreflect.FloatKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Float32 {
return nil, coderFloatPackedSlice
}
case protoreflect.Sfixed64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int64 {
return nil, coderSfixed64PackedSlice
}
case protoreflect.Fixed64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Uint64 {
return nil, coderFixed64PackedSlice
}
case protoreflect.DoubleKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Float64 {
return nil, coderDoublePackedSlice
}
}
case fd.Kind() == protoreflect.MessageKind:
2020-12-25 09:02:44 +01:00
return getMessageInfo(ft), makeMessageFieldCoder(fd, ft)
case fd.Kind() == protoreflect.GroupKind:
2020-12-25 09:02:44 +01:00
return getMessageInfo(ft), makeGroupFieldCoder(fd, ft)
case fd.Syntax() == protoreflect.Proto3 && fd.ContainingOneof() == nil:
2020-12-25 09:02:44 +01:00
// Populated oneof fields always encode even if set to the zero value,
// which normally are not encoded in proto3.
switch fd.Kind() {
case protoreflect.BoolKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Bool {
return nil, coderBoolNoZero
}
case protoreflect.EnumKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int32 {
return nil, coderEnumNoZero
}
case protoreflect.Int32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int32 {
return nil, coderInt32NoZero
}
case protoreflect.Sint32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int32 {
return nil, coderSint32NoZero
}
case protoreflect.Uint32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Uint32 {
return nil, coderUint32NoZero
}
case protoreflect.Int64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int64 {
return nil, coderInt64NoZero
}
case protoreflect.Sint64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int64 {
return nil, coderSint64NoZero
}
case protoreflect.Uint64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Uint64 {
return nil, coderUint64NoZero
}
case protoreflect.Sfixed32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int32 {
return nil, coderSfixed32NoZero
}
case protoreflect.Fixed32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Uint32 {
return nil, coderFixed32NoZero
}
case protoreflect.FloatKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Float32 {
return nil, coderFloatNoZero
}
case protoreflect.Sfixed64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int64 {
return nil, coderSfixed64NoZero
}
case protoreflect.Fixed64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Uint64 {
return nil, coderFixed64NoZero
}
case protoreflect.DoubleKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Float64 {
return nil, coderDoubleNoZero
}
case protoreflect.StringKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.String && strs.EnforceUTF8(fd) {
return nil, coderStringNoZeroValidateUTF8
}
if ft.Kind() == reflect.String {
return nil, coderStringNoZero
}
if ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8 && strs.EnforceUTF8(fd) {
return nil, coderBytesNoZeroValidateUTF8
}
if ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8 {
return nil, coderBytesNoZero
}
case protoreflect.BytesKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.String {
return nil, coderStringNoZero
}
if ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8 {
return nil, coderBytesNoZero
}
}
case ft.Kind() == reflect.Ptr:
ft := ft.Elem()
switch fd.Kind() {
case protoreflect.BoolKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Bool {
return nil, coderBoolPtr
}
case protoreflect.EnumKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int32 {
return nil, coderEnumPtr
}
case protoreflect.Int32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int32 {
return nil, coderInt32Ptr
}
case protoreflect.Sint32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int32 {
return nil, coderSint32Ptr
}
case protoreflect.Uint32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Uint32 {
return nil, coderUint32Ptr
}
case protoreflect.Int64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int64 {
return nil, coderInt64Ptr
}
case protoreflect.Sint64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int64 {
return nil, coderSint64Ptr
}
case protoreflect.Uint64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Uint64 {
return nil, coderUint64Ptr
}
case protoreflect.Sfixed32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int32 {
return nil, coderSfixed32Ptr
}
case protoreflect.Fixed32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Uint32 {
return nil, coderFixed32Ptr
}
case protoreflect.FloatKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Float32 {
return nil, coderFloatPtr
}
case protoreflect.Sfixed64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int64 {
return nil, coderSfixed64Ptr
}
case protoreflect.Fixed64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Uint64 {
return nil, coderFixed64Ptr
}
case protoreflect.DoubleKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Float64 {
return nil, coderDoublePtr
}
case protoreflect.StringKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.String && strs.EnforceUTF8(fd) {
return nil, coderStringPtrValidateUTF8
}
if ft.Kind() == reflect.String {
return nil, coderStringPtr
}
case protoreflect.BytesKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.String {
return nil, coderStringPtr
}
}
default:
switch fd.Kind() {
case protoreflect.BoolKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Bool {
return nil, coderBool
}
case protoreflect.EnumKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int32 {
return nil, coderEnum
}
case protoreflect.Int32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int32 {
return nil, coderInt32
}
case protoreflect.Sint32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int32 {
return nil, coderSint32
}
case protoreflect.Uint32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Uint32 {
return nil, coderUint32
}
case protoreflect.Int64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int64 {
return nil, coderInt64
}
case protoreflect.Sint64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int64 {
return nil, coderSint64
}
case protoreflect.Uint64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Uint64 {
return nil, coderUint64
}
case protoreflect.Sfixed32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int32 {
return nil, coderSfixed32
}
case protoreflect.Fixed32Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Uint32 {
return nil, coderFixed32
}
case protoreflect.FloatKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Float32 {
return nil, coderFloat
}
case protoreflect.Sfixed64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Int64 {
return nil, coderSfixed64
}
case protoreflect.Fixed64Kind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Uint64 {
return nil, coderFixed64
}
case protoreflect.DoubleKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.Float64 {
return nil, coderDouble
}
case protoreflect.StringKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.String && strs.EnforceUTF8(fd) {
return nil, coderStringValidateUTF8
}
if ft.Kind() == reflect.String {
return nil, coderString
}
if ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8 && strs.EnforceUTF8(fd) {
return nil, coderBytesValidateUTF8
}
if ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8 {
return nil, coderBytes
}
case protoreflect.BytesKind:
2020-12-25 09:02:44 +01:00
if ft.Kind() == reflect.String {
return nil, coderString
}
if ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8 {
return nil, coderBytes
}
}
}
panic(fmt.Sprintf("invalid type: no encoder for %v %v %v/%v", fd.FullName(), fd.Cardinality(), fd.Kind(), ft))
}
// encoderFuncsForValue returns value functions for a field, used for
// extension values and map encoding.
func encoderFuncsForValue(fd protoreflect.FieldDescriptor) valueCoderFuncs {
2020-12-25 09:02:44 +01:00
switch {
case fd.Cardinality() == protoreflect.Repeated && !fd.IsPacked():
2020-12-25 09:02:44 +01:00
switch fd.Kind() {
case protoreflect.BoolKind:
2020-12-25 09:02:44 +01:00
return coderBoolSliceValue
case protoreflect.EnumKind:
2020-12-25 09:02:44 +01:00
return coderEnumSliceValue
case protoreflect.Int32Kind:
2020-12-25 09:02:44 +01:00
return coderInt32SliceValue
case protoreflect.Sint32Kind:
2020-12-25 09:02:44 +01:00
return coderSint32SliceValue
case protoreflect.Uint32Kind:
2020-12-25 09:02:44 +01:00
return coderUint32SliceValue
case protoreflect.Int64Kind:
2020-12-25 09:02:44 +01:00
return coderInt64SliceValue
case protoreflect.Sint64Kind:
2020-12-25 09:02:44 +01:00
return coderSint64SliceValue
case protoreflect.Uint64Kind:
2020-12-25 09:02:44 +01:00
return coderUint64SliceValue
case protoreflect.Sfixed32Kind:
2020-12-25 09:02:44 +01:00
return coderSfixed32SliceValue
case protoreflect.Fixed32Kind:
2020-12-25 09:02:44 +01:00
return coderFixed32SliceValue
case protoreflect.FloatKind:
2020-12-25 09:02:44 +01:00
return coderFloatSliceValue
case protoreflect.Sfixed64Kind:
2020-12-25 09:02:44 +01:00
return coderSfixed64SliceValue
case protoreflect.Fixed64Kind:
2020-12-25 09:02:44 +01:00
return coderFixed64SliceValue
case protoreflect.DoubleKind:
2020-12-25 09:02:44 +01:00
return coderDoubleSliceValue
case protoreflect.StringKind:
2020-12-25 09:02:44 +01:00
// We don't have a UTF-8 validating coder for repeated string fields.
// Value coders are used for extensions and maps.
// Extensions are never proto3, and maps never contain lists.
return coderStringSliceValue
case protoreflect.BytesKind:
2020-12-25 09:02:44 +01:00
return coderBytesSliceValue
case protoreflect.MessageKind:
2020-12-25 09:02:44 +01:00
return coderMessageSliceValue
case protoreflect.GroupKind:
2020-12-25 09:02:44 +01:00
return coderGroupSliceValue
}
case fd.Cardinality() == protoreflect.Repeated && fd.IsPacked():
2020-12-25 09:02:44 +01:00
switch fd.Kind() {
case protoreflect.BoolKind:
2020-12-25 09:02:44 +01:00
return coderBoolPackedSliceValue
case protoreflect.EnumKind:
2020-12-25 09:02:44 +01:00
return coderEnumPackedSliceValue
case protoreflect.Int32Kind:
2020-12-25 09:02:44 +01:00
return coderInt32PackedSliceValue
case protoreflect.Sint32Kind:
2020-12-25 09:02:44 +01:00
return coderSint32PackedSliceValue
case protoreflect.Uint32Kind:
2020-12-25 09:02:44 +01:00
return coderUint32PackedSliceValue
case protoreflect.Int64Kind:
2020-12-25 09:02:44 +01:00
return coderInt64PackedSliceValue
case protoreflect.Sint64Kind:
2020-12-25 09:02:44 +01:00
return coderSint64PackedSliceValue
case protoreflect.Uint64Kind:
2020-12-25 09:02:44 +01:00
return coderUint64PackedSliceValue
case protoreflect.Sfixed32Kind:
2020-12-25 09:02:44 +01:00
return coderSfixed32PackedSliceValue
case protoreflect.Fixed32Kind:
2020-12-25 09:02:44 +01:00
return coderFixed32PackedSliceValue
case protoreflect.FloatKind:
2020-12-25 09:02:44 +01:00
return coderFloatPackedSliceValue
case protoreflect.Sfixed64Kind:
2020-12-25 09:02:44 +01:00
return coderSfixed64PackedSliceValue
case protoreflect.Fixed64Kind:
2020-12-25 09:02:44 +01:00
return coderFixed64PackedSliceValue
case protoreflect.DoubleKind:
2020-12-25 09:02:44 +01:00
return coderDoublePackedSliceValue
}
default:
switch fd.Kind() {
default:
case protoreflect.BoolKind:
2020-12-25 09:02:44 +01:00
return coderBoolValue
case protoreflect.EnumKind:
2020-12-25 09:02:44 +01:00
return coderEnumValue
case protoreflect.Int32Kind:
2020-12-25 09:02:44 +01:00
return coderInt32Value
case protoreflect.Sint32Kind:
2020-12-25 09:02:44 +01:00
return coderSint32Value
case protoreflect.Uint32Kind:
2020-12-25 09:02:44 +01:00
return coderUint32Value
case protoreflect.Int64Kind:
2020-12-25 09:02:44 +01:00
return coderInt64Value
case protoreflect.Sint64Kind:
2020-12-25 09:02:44 +01:00
return coderSint64Value
case protoreflect.Uint64Kind:
2020-12-25 09:02:44 +01:00
return coderUint64Value
case protoreflect.Sfixed32Kind:
2020-12-25 09:02:44 +01:00
return coderSfixed32Value
case protoreflect.Fixed32Kind:
2020-12-25 09:02:44 +01:00
return coderFixed32Value
case protoreflect.FloatKind:
2020-12-25 09:02:44 +01:00
return coderFloatValue
case protoreflect.Sfixed64Kind:
2020-12-25 09:02:44 +01:00
return coderSfixed64Value
case protoreflect.Fixed64Kind:
2020-12-25 09:02:44 +01:00
return coderFixed64Value
case protoreflect.DoubleKind:
2020-12-25 09:02:44 +01:00
return coderDoubleValue
case protoreflect.StringKind:
2020-12-25 09:02:44 +01:00
if strs.EnforceUTF8(fd) {
return coderStringValueValidateUTF8
}
return coderStringValue
case protoreflect.BytesKind:
2020-12-25 09:02:44 +01:00
return coderBytesValue
case protoreflect.MessageKind:
2020-12-25 09:02:44 +01:00
return coderMessageValue
case protoreflect.GroupKind:
2020-12-25 09:02:44 +01:00
return coderGroupValue
}
}
panic(fmt.Sprintf("invalid field: no encoder for %v %v %v", fd.FullName(), fd.Cardinality(), fd.Kind()))
}