Documentation
¶
Overview ¶
Package value provides functionality for wrapping Go values to implement protoreflect values.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Converter ¶
type Converter struct { PBValueOf func(reflect.Value) pref.Value GoValueOf func(pref.Value) reflect.Value EnumType pref.EnumType MessageType pref.MessageType IsLegacy bool }
Converter provides functions for converting to/from Go reflect.Value types and protobuf protoreflect.Value types.
func NewConverter ¶
NewConverter matches a Go type with a protobuf kind and returns a Converter that converts between the two. NewConverter panics if it unable to provide a conversion between the two. The Converter methods also panic when they are called on incorrect Go types.
This matcher deliberately supports a wider range of Go types than what protoc-gen-go historically generated to be able to automatically wrap some v1 messages generated by other forks of protoc-gen-go.
func NewLegacyConverter ¶
NewLegacyConverter is identical to NewConverter, but supports wrapping legacy v1 messages to implement the v2 message API using the provided LegacyWrapper.
type LegacyEnum ¶
LegacyWrapper is a set of wrapper methods that wraps legacy v1 Go types to implement the v2 reflection APIs.
type LegacyMessage ¶
LegacyWrapper is a set of wrapper methods that wraps legacy v1 Go types to implement the v2 reflection APIs.
type LegacyWrapper ¶
type LegacyWrapper interface { EnumOf(interface{}) LegacyEnum EnumTypeOf(interface{}) pref.EnumType MessageOf(interface{}) LegacyMessage MessageTypeOf(interface{}) pref.MessageType ExtensionTypeOf(pref.ExtensionDescriptor, interface{}) pref.ExtensionType // TODO: Remove these eventually. // See the TODOs in internal/impl/legacy_extension.go. ExtensionDescFromType(pref.ExtensionType) *piface.ExtensionDescV1 ExtensionTypeFromDesc(*piface.ExtensionDescV1) pref.ExtensionType }
LegacyWrapper is a set of wrapper methods that wraps legacy v1 Go types to implement the v2 reflection APIs.