impl

package
v2.0.0-...-d24bc72 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2019 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterLegacyWrapper

func RegisterLegacyWrapper(w pvalue.LegacyWrapper)

RegisterLegacyWrapper registers a set of constructor functions that are called when a legacy enum or message is encountered that does not natively support the protobuf reflection APIs.

Types

type Export

type Export struct{}

Export is a zero-length named type that exists only to export a set of functions that we do not want to appear in godoc.

func (Export) CompressGZIP

func (Export) CompressGZIP(in []byte) (out []byte)

CompressGZIP compresses the input as a GZIP-encoded file. The current implementation does no compression.

func (Export) EnumOf

func (Export) EnumOf(e interface{}) pref.Enum

EnumOf returns the protoreflect.Enum interface over e. If e already implements proto.Enum, then it directly calls the ProtoReflect method, otherwise it wraps the v1 enum to implement the v2 reflective interface.

func (Export) EnumStringOf

func (Export) EnumStringOf(ed pref.EnumDescriptor, n pref.EnumNumber) string

EnumStringOf returns the enum value as a string, either as the name if the number is resolvable, or the number formatted as a string.

func (Export) EnumTypeOf

func (Export) EnumTypeOf(e interface{}) pref.EnumType

EnumTypeOf returns the protoreflect.EnumType for e. If e already implements proto.Enum, then it obtains the type by directly calling the ProtoReflect.Type method, otherwise it derives an enum type from the v1 named int32 type.

func (Export) ExtensionTypeOf

func (Export) ExtensionTypeOf(d pref.ExtensionDescriptor, t interface{}) pref.ExtensionType

ExtensionTypeOf returns a protoreflect.ExtensionType where the type of the field is t. The type t must be provided if the field is an enum or message. If t already implements proto.Enum or proto.Message, then this returns an extension type by directly calling prototype.GoExtension. Otherwise, it derives an extension type by wrapping the enum or message using EnumOf or MessageOf.

func (Export) MessageOf

func (Export) MessageOf(m interface{}) pref.Message

MessageOf returns the protoreflect.Message interface over m. If m already implements proto.Message, then it directly calls the ProtoReflect method, otherwise it wraps the v1 message to implement the v2 reflective interface.

func (Export) MessageStringOf

func (Export) MessageStringOf(m pref.ProtoMessage) string

MessageStringOf returns the message value as a string, which is the message serialized in the protobuf text format.

func (Export) MessageTypeOf

func (Export) MessageTypeOf(m interface{}) pref.MessageType

MessageTypeOf returns the protoreflect.MessageType for m. If m already implements proto.Message, then it obtains the type by directly calling the ProtoReflect.Type method, otherwise it derives a message type from the v1 message struct.

func (Export) UnmarshalJSONEnum

func (Export) UnmarshalJSONEnum(ed pref.EnumDescriptor, b []byte) (pref.EnumNumber, error)

UnmarshalJSONEnum unmarshals an enum from a JSON-encoded input. The input can either be a string representing the enum value by name, or a number representing the enum number itself.

type ExtensionFieldV1

type ExtensionFieldV1 struct {

	// When an extension is stored in a message using SetExtension
	// only desc and value are set. When the message is marshaled
	// Raw will be set to the encoded form of the message.
	//
	// When a message is unmarshaled and contains extensions, each
	// extension will have only Raw set. When such an extension is
	// accessed using GetExtension (or GetExtensions) desc and value
	// will be set.
	Desc *piface.ExtensionDescV1 // TODO: switch to protoreflect.ExtensionType

	// Value is a concrete value for the extension field. Let the type of
	// Desc.ExtensionType be the "API type" and the type of Value be the
	// "storage type". The API type and storage type are the same except:
	//	* for scalars (except []byte), where the API type uses *T,
	//	while the storage type uses T.
	//	* for repeated fields, where the API type uses []T,
	//	while the storage type uses *[]T.
	//
	// The reason for the divergence is so that the storage type more naturally
	// matches what is expected of when retrieving the values through the
	// protobuf reflection APIs.
	//
	// The Value may only be populated if Desc is also populated.
	Value interface{} // TODO: switch to protoreflect.Value

	// Raw is the raw encoded bytes for the extension field.
	// It is possible for Raw to be populated irrespective of whether the
	// other fields are populated.
	Raw []byte // TODO: remove; let this be handled by XXX_unrecognized
}

type MessageType

type MessageType struct {
	// GoType is the underlying message Go type and must be populated.
	// Once set, this field must never be mutated.
	GoType reflect.Type // pointer to struct

	// PBType is the underlying message descriptor type and must be populated.
	// Once set, this field must never be mutated.
	PBType pref.MessageType
	// contains filtered or unexported fields
}

MessageType provides protobuf related functionality for a given Go type that represents a message. A given instance of MessageType is tied to exactly one Go type, which must be a pointer to a struct type.

func (*MessageType) MessageOf

func (mi *MessageType) MessageOf(p interface{}) pref.Message

func (*MessageType) Methods

func (mi *MessageType) Methods() *piface.Methods

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL