Documentation
¶
Overview ¶
Package protoutil contains functions for working with protobuf types.
Index ¶
- Variables
- func GetTypeURL(msg proto.Message) string
- func NewAny(msg proto.Message) *anypb.Any
- func NewAnyBool(v bool) *anypb.Any
- func NewAnyBytes(v []byte) *anypb.Any
- func NewAnyDouble(v float64) *anypb.Any
- func NewAnyFloat(v float32) *anypb.Any
- func NewAnyInt32(v int32) *anypb.Any
- func NewAnyInt64(v int64) *anypb.Any
- func NewAnyNull() *anypb.Any
- func NewAnyString(v string) *anypb.Any
- func NewAnyUInt32(v uint32) *anypb.Any
- func NewAnyUInt64(v uint64) *anypb.Any
- func NewStructBool(v bool) *structpb.Value
- func NewStructList(vs ...*structpb.Value) *structpb.Value
- func NewStructMap(v map[string]*structpb.Value) *structpb.Value
- func NewStructNull() *structpb.Value
- func NewStructNumber(v float64) *structpb.Value
- func NewStructString(v string) *structpb.Value
- func OverwriteMasked(dst, src proto.Message, m *fieldmaskpb.FieldMask) error
- func ToAny(value any) *anypb.Any
- func ToStruct(value any) *structpb.Value
- func Transform(msg proto.Message, f TransformFunc) (proto.Message, error)
- func UnmarshalAnyJSON(data []byte) (*anypb.Any, error)
- type Decryptor
- type Encryptor
- type TransformFunc
Constants ¶
This section is empty.
Variables ¶
var ErrDescriptorMismatch = errors.New("descriptor mismatch")
ErrDescriptorMismatch indicates an operation could not be performed because two proto messages did not have identical descriptors.
Functions ¶
func GetTypeURL ¶ added in v0.14.0
GetTypeURL gets the TypeURL for a protobuf message.
func NewAnyBytes ¶
NewAnyBytes creates a new any type from bytes.
func NewAnyDouble ¶
NewAnyDouble creates a new any type from a float64.
func NewAnyFloat ¶
NewAnyFloat creates a new any type from a float32.
func NewAnyInt32 ¶
NewAnyInt32 creates a new any type from an int32.
func NewAnyInt64 ¶
NewAnyInt64 creates a new any type from an int64.
func NewAnyNull ¶
NewAnyNull creates a new any type from a null struct.
func NewAnyString ¶
NewAnyString creates a new any type from a string.
func NewAnyUInt32 ¶
NewAnyUInt32 creates a new any type from an uint32.
func NewAnyUInt64 ¶
NewAnyUInt64 creates a new any type from an uint64.
func NewStructBool ¶
NewStructBool creates a new bool struct value.
func NewStructList ¶
NewStructList creates a new list struct value.
func NewStructMap ¶
NewStructMap creates a new map struct value.
func NewStructNull ¶
NewStructNull creates a new null struct value.
func NewStructNumber ¶
NewStructNumber creates a new number struct value.
func NewStructString ¶
NewStructString creates a new string struct value.
func OverwriteMasked ¶ added in v0.24.0
func OverwriteMasked(dst, src proto.Message, m *fieldmaskpb.FieldMask) error
OverwriteMasked copies values from src to dst subject to a field mask. It will will return an error if dst and src are not the same type of message, or if some path in the field mask is not valid for that message type.
Types ¶
type Decryptor ¶ added in v0.14.0
type Decryptor struct {
// contains filtered or unexported fields
}
A Decryptor decrypts encrypted protobuf messages.
func NewDecryptor ¶ added in v0.14.0
func NewDecryptor(keySource cryptutil.KeyEncryptionKeySource) *Decryptor
NewDecryptor creates a new decryptor.
type Encryptor ¶ added in v0.14.0
An Encryptor encrypts protobuf messages using a key encryption key and periodically rotated generated data encryption keys.
func NewEncryptor ¶ added in v0.14.0
func NewEncryptor(kek *cryptutil.PublicKeyEncryptionKey) *Encryptor
NewEncryptor returns a new protobuf Encryptor.
type TransformFunc ¶ added in v0.14.0
type TransformFunc func(protoreflect.FieldDescriptor, protoreflect.Value) (protoreflect.Value, error)
TransformFunc is a function that transforms a protobuf value into a new protobuf value.