package impl

Import Path
	google.golang.org/protobuf/internal/impl (on go.dev)

Dependency Relation
	imports 34 packages, and imported by 2 packages


Package-Level Type Names (total 77, in which 13 are exported)
/* sort exporteds by: | */
A Converter coverts to/from Go reflect.Value types and protobuf protoreflect.Value types. GoValueOf converts a protoreflect.Value to a reflect.Value. IsValidGo returns whether a reflect.Value is compatible with this type. IsValidPB returns whether a protoreflect.Value is compatible with this type. New returns a new field value. For scalars, it returns the default value of the field. For composite types, it returns a new mutable value. PBValueOf converts a reflect.Value to a protoreflect.Value. Zero returns a new field value. For scalars, it returns the default value of the field. For composite types, it returns an immutable, empty value. func NewConverter(t reflect.Type, fd pref.FieldDescriptor) Converter
Desc pref.EnumDescriptor // int32 kind (*T) Descriptor() pref.EnumDescriptor (*T) New(n pref.EnumNumber) pref.Enum *T : google.golang.org/protobuf/reflect/protoreflect.EnumType
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. ( T) ClearWeak(w *WeakFields, num pref.FieldNumber) CompressGZIP compresses the input as a GZIP-encoded file. The current implementation does no compression. EnumDescriptorOf returns the protoreflect.EnumDescriptor for e. It returns nil if e is nil. EnumOf returns the protoreflect.Enum interface over e. It returns nil if e is nil. EnumStringOf returns the enum value as a string, either as the name if the number is resolvable, or the number formatted as a string. EnumTypeOf returns the protoreflect.EnumType for e. It returns nil if e is nil. ( T) GetWeak(w WeakFields, num pref.FieldNumber, name pref.FullName) pref.ProtoMessage ( T) HasWeak(w WeakFields, num pref.FieldNumber) bool LegacyEnumName returns the name of enums used in legacy code. LegacyMessageTypeOf returns the protoreflect.MessageType for m, with name used as the message name if necessary. MessageDescriptorOf returns the protoreflect.MessageDescriptor for m. It returns nil if m is nil. MessageOf returns the protoreflect.Message interface over m. It returns nil if m is nil. ( T) MessageStateOf(p Pointer) *messageState MessageStringOf returns the message value as a string, which is the message serialized in the protobuf text format. MessageTypeOf returns the protoreflect.MessageType for m. It returns nil if m is nil. NewError formats a string according to the format specifier and arguments and returns an error that has a "proto" prefix. ProtoMessageV1Of converts either a v1 or v2 message to a v1 message. It returns nil if m is nil. ProtoMessageV2Of converts either a v1 or v2 message to a v2 message. It returns nil if m is nil. ( T) SetWeak(w *WeakFields, num pref.FieldNumber, name pref.FullName, m pref.ProtoMessage) 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. var google.golang.org/protobuf/runtime/protoimpl.X
IsSet returns whether the extension field is set. This may be called concurrently. Set sets the type and value of the extension field. This must not be called concurrently. SetLazy sets the type and a value that is to be lazily evaluated upon first use. This must not be called concurrently. Type returns the type of the extension field. This may be called concurrently. Value returns the value of the extension field. This may be called concurrently.
type ExtensionFields = (map)
ExtensionInfo implements ExtensionType. This type contains a number of exported fields for legacy compatibility. The only non-deprecated use of this type is through the methods of the ExtensionType interface. ExtendedType is a typed nil-pointer to the parent message type that is being extended. It is possible for this to be unpopulated in v2 since the message may no longer implement the MessageV1 interface. Deprecated: Use the ExtendedType method instead. ExtensionType is the zero value of the extension type. For historical reasons, reflect.TypeOf(ExtensionType) and the type returned by InterfaceOf may not be identical. Deprecated: Use InterfaceOf(xt.Zero()) instead. Field is the field number of the extension. Deprecated: Use the Descriptor().Number method instead. Filename is the proto filename in which the extension is defined. Deprecated: Use Descriptor().ParentFile().Path() instead. Name is the fully qualified name of extension. Deprecated: Use the Descriptor().FullName method instead. Tag is the protobuf struct tag used in the v1 API. Deprecated: Do not use. (*T) InterfaceOf(v pref.Value) interface{} (*T) IsValidInterface(v interface{}) bool (*T) IsValidValue(v pref.Value) bool (*T) New() pref.Value (*T) TypeDescriptor() pref.ExtensionTypeDescriptor (*T) ValueOf(v interface{}) pref.Value (*T) Zero() pref.Value *T : google.golang.org/protobuf/reflect/protoreflect.ExtensionType func github.com/golang/protobuf/proto.ExtensionDescs(m proto.Message) ([]*proto.ExtensionDesc, error) func InitExtensionInfo(xi *ExtensionInfo, xd pref.ExtensionDescriptor, goType reflect.Type) func github.com/golang/protobuf/proto.ClearExtension(m proto.Message, xt *proto.ExtensionDesc) func github.com/golang/protobuf/proto.GetExtension(m proto.Message, xt *proto.ExtensionDesc) (interface{}, error) func github.com/golang/protobuf/proto.GetExtensions(m proto.Message, xts []*proto.ExtensionDesc) ([]interface{}, error) func github.com/golang/protobuf/proto.HasExtension(m proto.Message, xt *proto.ExtensionDesc) (has bool) func github.com/golang/protobuf/proto.RegisterExtension(d *proto.ExtensionDesc) func github.com/golang/protobuf/proto.SetExtension(m proto.Message, xt *proto.ExtensionDesc, v interface{}) error var google.golang.org/genproto/googleapis/api/annotations.E_DefaultHost *ExtensionInfo var google.golang.org/genproto/googleapis/api/annotations.E_FieldBehavior *ExtensionInfo var google.golang.org/genproto/googleapis/api/annotations.E_Http *ExtensionInfo var google.golang.org/genproto/googleapis/api/annotations.E_MethodSignature *ExtensionInfo var google.golang.org/genproto/googleapis/api/annotations.E_OauthScopes *ExtensionInfo var google.golang.org/genproto/googleapis/api/annotations.E_Resource *ExtensionInfo var google.golang.org/genproto/googleapis/api/annotations.E_ResourceDefinition *ExtensionInfo var google.golang.org/genproto/googleapis/api/annotations.E_ResourceReference *ExtensionInfo
MessageInfo provides protobuf related functionality for a given Go type that represents a message. A given instance of MessageInfo is tied to exactly one Go type, which must be a pointer to a struct type. The exported fields must be populated before any methods are called and cannot be mutated after set. Desc is the underlying message descriptor type and must be populated. Exporter must be provided in a purego environment in order to provide access to unexported fields. GoReflectType is the underlying message Go type and must be populated. // pointer to struct OneofWrappers is list of pointers to oneof wrapper struct types. (*T) Descriptor() protoreflect.MessageDescriptor (*T) Enum(i int) protoreflect.EnumType (*T) Message(i int) protoreflect.MessageType MessageOf returns a reflective view over a message. The input must be a pointer to a named Go struct. If the provided type has a ProtoReflect method, it must be implemented by calling this method. (*T) New() protoreflect.Message (*T) Zero() protoreflect.Message *T : google.golang.org/protobuf/reflect/protoreflect.MessageFieldTypes *T : google.golang.org/protobuf/reflect/protoreflect.MessageType
MessageState is a data structure that is nested as the first field in a concrete message. It provides a way to implement the ProtoReflect method in an allocation-free way without needing to have a shadow Go type generated for every message type. This technique only works using unsafe. Example generated code: type M struct { state protoimpl.MessageState Field1 int32 Field2 string Field3 *BarMessage ... } func (m *M) ProtoReflect() protoreflect.Message { mi := &file_fizz_buzz_proto_msgInfos[5] if protoimpl.UnsafeEnabled && m != nil { ms := protoimpl.X.MessageStateOf(Pointer(m)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(m) } The MessageState type holds a *MessageInfo, which must be atomically set to the message info associated with a given message instance. By unsafely converting a *M into a *MessageState, the MessageState object has access to all the information needed to implement protobuf reflection. It has access to the message info as its first field, and a pointer to the MessageState is identical to a pointer to the concrete message value. Requirements: • The type M must implement protoreflect.ProtoMessage. • The address of m must not be nil. • The address of m and the address of m.state must be equal, even though they are different Go types. DoNotCompare pragma.DoNotCompare DoNotCopy pragma.DoNotCopy NoUnkeyedLiterals pragma.NoUnkeyedLiterals
Pointer is an opaque pointer type. func Export.MessageStateOf(p Pointer) *messageState
type SizeCache = int32 (basic type)
ValidationStatus is the result of validating the wire-format encoding of a message. ( T) String() string T : fmt.Stringer func Validate(mt pref.MessageType, in piface.UnmarshalInput) (out piface.UnmarshalOutput, _ ValidationStatus) const ValidationInvalid const ValidationUnknown const ValidationValid
type WeakFields = (map)
Package-Level Functions (total 486, in which 7 are exported)
AberrantDeriveFullName derives a fully qualified protobuf name for the given Go type The provided name is not guaranteed to be stable nor universally unique. It should be sufficiently unique within a program. This is exported for testing purposes.
IsLazy reports whether a field is lazily encoded. It is exported for testing.
LegacyLoadEnumDesc returns an EnumDescriptor derived from the Go type, which must be an int32 kind and not implement the v2 API already. This is exported for testing purposes.
LegacyLoadMessageDesc returns an MessageDescriptor derived from the Go type, which should be a *struct kind and must not implement the v2 API already. This is exported for testing purposes.
NewConverter matches a Go type with a protobuf field and returns a Converter that converts between the two. Enums must be a named int32 kind that implements protoreflect.Enum, and messages must be pointer to a named struct type that implements protoreflect.ProtoMessage. 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.
Validate determines whether the contents of the buffer are a valid wire encoding of the message type. This function is exposed for testing.
Package-Level Variables (total 180, none are exported)
Package-Level Constants (total 22, in which 4 are exported)
const UnsafeEnabled = true
ValidationInvalid indicates that unmarshaling the message will fail.
ValidationUnknown indicates that unmarshaling the message might succeed or fail. The validator was unable to render a judgement. The only causes of this status are an aberrant message type appearing somewhere in the message or a failure in the extension resolver.
ValidationValid indicates that unmarshaling the message will succeed.