protoutil

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: Apache-2.0 Imports: 12 Imported by: 3

Documentation

Overview

Package protoutil contains functions for working with protobuf types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTypeURL added in v0.14.0

func GetTypeURL(msg proto.Message) string

GetTypeURL gets the TypeURL for a protobuf message.

func NewAny added in v0.15.4

func NewAny(msg proto.Message) *anypb.Any

NewAny creates a new Any using deterministic serialization.

func NewAnyBool

func NewAnyBool(v bool) *anypb.Any

NewAnyBool creates a new any type from a bool.

func NewAnyBytes

func NewAnyBytes(v []byte) *anypb.Any

NewAnyBytes creates a new any type from bytes.

func NewAnyDouble

func NewAnyDouble(v float64) *anypb.Any

NewAnyDouble creates a new any type from a float64.

func NewAnyFloat

func NewAnyFloat(v float32) *anypb.Any

NewAnyFloat creates a new any type from a float32.

func NewAnyInt32

func NewAnyInt32(v int32) *anypb.Any

NewAnyInt32 creates a new any type from an int32.

func NewAnyInt64

func NewAnyInt64(v int64) *anypb.Any

NewAnyInt64 creates a new any type from an int64.

func NewAnyNull

func NewAnyNull() *anypb.Any

NewAnyNull creates a new any type from a null struct.

func NewAnyString

func NewAnyString(v string) *anypb.Any

NewAnyString creates a new any type from a string.

func NewAnyUInt32

func NewAnyUInt32(v uint32) *anypb.Any

NewAnyUInt32 creates a new any type from an uint32.

func NewAnyUInt64

func NewAnyUInt64(v uint64) *anypb.Any

NewAnyUInt64 creates a new any type from an uint64.

func NewStructBool

func NewStructBool(v bool) *structpb.Value

NewStructBool creates a new bool struct value.

func NewStructList

func NewStructList(vs ...*structpb.Value) *structpb.Value

NewStructList creates a new list struct value.

func NewStructMap

func NewStructMap(v map[string]*structpb.Value) *structpb.Value

NewStructMap creates a new map struct value.

func NewStructNull

func NewStructNull() *structpb.Value

NewStructNull creates a new null struct value.

func NewStructNumber

func NewStructNumber(v float64) *structpb.Value

NewStructNumber creates a new number struct value.

func NewStructString

func NewStructString(v string) *structpb.Value

NewStructString creates a new string struct value.

func ToAny

func ToAny(value interface{}) *anypb.Any

ToAny converts any type into an any value.

func ToStruct

func ToStruct(value interface{}) *structpb.Value

ToStruct converts any value into a structpb Value.

func Transform added in v0.14.0

func Transform(msg proto.Message, f TransformFunc) (proto.Message, error)

Transform takes in a protobuf message and transforms any basic values with the given function.

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.

func (*Decryptor) Decrypt added in v0.14.0

func (dec *Decryptor) Decrypt(src *cryptpb.SealedMessage) (proto.Message, error)

Decrypt decrypts an encrypted protobuf message.

type Encryptor added in v0.14.0

type Encryptor struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

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.

func (*Encryptor) Encrypt added in v0.14.0

func (enc *Encryptor) Encrypt(msg proto.Message) (*cryptpb.SealedMessage, error)

Encrypt encrypts a protobuf message.

type TransformFunc added in v0.14.0

TransformFunc is a function that transforms a protobuf value into a new protobuf value.

Jump to

Keyboard shortcuts

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