protos

package
v0.0.360 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const TypeUrlPrefix = "type.googleapis.com/"

Variables

This section is empty.

Functions

func AllocateDynamicMessage added in v0.0.145

func AllocateDynamicMessage(ctx context.Context, pctx ParseContext, messageType protoreflect.MessageDescriptor, value any) (protoreflect.ProtoMessage, error)

func AllocateFileContents added in v0.0.167

func AllocateFileContents(ctx context.Context, pctx ParseContext, value any) (*schema.FileContents, error)

func AllocateFrom added in v0.0.145

func AllocateFrom(ctx context.Context, pctx ParseContext, value map[string]any) (proto.Message, error)

func AllocateWellKnownMessage added in v0.0.145

func AllocateWellKnownMessage(ctx context.Context, pctx ParseContext, messageType protoreflect.MessageDescriptor, value any) (protoreflect.ProtoMessage, error)

func CheckConsolidate

func CheckConsolidate[V proto.Message](check V, out *V) bool

func Clone

func Clone[V proto.Message](msg V) V

func NewFromType

func NewFromType[V proto.Message]() V

func TypeUrl

func TypeUrl[V proto.Message]() string

func TypeUrlForInstance

func TypeUrlForInstance(m proto.Message) string

func WrapAnyOrDie

func WrapAnyOrDie(src protoreflect.ProtoMessage) *anypb.Any

func WrapAnysOrDie

func WrapAnysOrDie(srcs ...protoreflect.ProtoMessage) []*anypb.Any

func WriteFile

func WriteFile(path string, msg proto.Message) error

Types

type ParseContext added in v0.0.145

type ParseContext struct {
	SupportWellKnownMessages bool
	FS                       fs.FS
	PackageName              schema.PackageName
	EnsurePackage            func(schema.PackageName) error
}

type SerializeOpts

type SerializeOpts struct {
	TextProto bool
	JSON      bool
	Resolver  interface {
		protoregistry.ExtensionTypeResolver
		protoregistry.MessageTypeResolver
	}
}

func (SerializeOpts) Serialize

func (opts SerializeOpts) Serialize(msgs ...proto.Message) ([]TextAndBinary, error)

func (SerializeOpts) SerializeToFS

func (opts SerializeOpts) SerializeToFS(ctx context.Context, target fnfs.WriteFS, m map[string]proto.Message) error

type TextAndBinary

type TextAndBinary struct {
	Text   []byte
	JSON   []byte
	Binary []byte

	PerFormat map[string][]byte // Key, one of: binarypb, textpb, json
}

func SerializeMultiple

func SerializeMultiple(msgs ...proto.Message) ([]TextAndBinary, error)

Jump to

Keyboard shortcuts

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