protoencoding

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReparseUnrecognized

func ReparseUnrecognized(resolver Resolver, reflectMessage protoreflect.Message) error

ReparseUnrecognized uses the given resolver to parse any unrecognized fields in the given reflectMessage. It does so recursively, resolving any unrecognized fields in nested messages.

Types

type JSONMarshalerOption

type JSONMarshalerOption func(*jsonMarshaler)

JSONMarshalerOption is an option for a new JSONMarshaler.

func JSONMarshalerWithEmitUnpopulated

func JSONMarshalerWithEmitUnpopulated() JSONMarshalerOption

JSONMarshalerWithEmitUnpopulated says to emit unpopulated values

func JSONMarshalerWithIndent

func JSONMarshalerWithIndent() JSONMarshalerOption

JSONMarshalerWithIndent says to use an indent of two spaces.

func JSONMarshalerWithUseEnumNumbers

func JSONMarshalerWithUseEnumNumbers() JSONMarshalerOption

JSONMarshalerWithUseEnumNumbers says to use enum numbers.

func JSONMarshalerWithUseProtoNames

func JSONMarshalerWithUseProtoNames() JSONMarshalerOption

JSONMarshalerWithUseProtoNames says to use proto names.

type JSONUnmarshalerOption

type JSONUnmarshalerOption func(*jsonUnmarshaler)

JSONUnmarshalerOption is an option for a new JSONUnmarshaler.

func JSONUnmarshalerWithDisallowUnknown

func JSONUnmarshalerWithDisallowUnknown() JSONUnmarshalerOption

JSONUnmarshalerWithDisallowUnknown says to disallow unrecognized fields.

type Marshaler

type Marshaler interface {
	Marshal(message proto.Message) ([]byte, error)
}

Marshaler marshals Messages.

func NewJSONMarshaler

func NewJSONMarshaler(resolver Resolver, options ...JSONMarshalerOption) Marshaler

NewJSONMarshaler returns a new Marshaler for JSON.

This has the potential to be unstable over time. resolver can be nil if unknown and is only needed for extensions.

func NewTxtpbMarshaler

func NewTxtpbMarshaler(resolver Resolver) Marshaler

NewTxtpbMarshaler returns a new Marshaler for txtpb.

resolver can be nil if unknown and is only needed for extensions.

func NewWireMarshaler

func NewWireMarshaler() Marshaler

NewWireMarshaler returns a new Marshaler for wire.

See https://godoc.org/google.golang.org/protobuf/proto#MarshalOptions for a discussion on stability. This has the potential to be unstable over time.

func NewYAMLMarshaler

func NewYAMLMarshaler(resolver Resolver, options ...YAMLMarshalerOption) Marshaler

NewYAMLMarshaler returns a new Marshaler for YAML.

resolver can be nil if unknown and is only needed for extensions.

type Resolver

Resolver can resolve files, messages, enums, and extensions.

func CombineResolvers

func CombineResolvers(resolvers ...Resolver) Resolver

CombineResolvers returns a resolver that uses all of the given resolvers. It will use the first resolver, and if it returns an error, the second will be tried, and so on.

func NewLazyResolver

func NewLazyResolver[F protodescriptor.FileDescriptor](fileDescriptors ...F) Resolver

NewLazyResolver creates a new Resolver that is constructed from the given descriptors only as needed, if invoked.

If there is an error when constructing the resolver, it will be returned by all method calls of the returned resolver.

func NewResolver

func NewResolver[F protodescriptor.FileDescriptor](fileDescriptors ...F) (Resolver, error)

NewResolver creates a new Resolver.

If the input slice is empty, this returns nil The given FileDescriptors must be self-contained, that is they must contain all imports. This can NOT be guaranteed for FileDescriptorSets given over the wire, and can only be guaranteed from builds.

type Unmarshaler

type Unmarshaler interface {
	Unmarshal(data []byte, message proto.Message) error
}

Unmarshaler unmarshals Messages.

func NewJSONUnmarshaler

func NewJSONUnmarshaler(resolver Resolver, options ...JSONUnmarshalerOption) Unmarshaler

NewJSONUnmarshaler returns a new Unmarshaler for json.

resolver can be nil if unknown and are only needed for extensions.

func NewTxtpbUnmarshaler

func NewTxtpbUnmarshaler(resolver Resolver) Unmarshaler

NewTxtpbUnmarshaler returns a new Unmarshaler for txtpb.

resolver can be nil if unknown and are only needed for extensions.

func NewWireUnmarshaler

func NewWireUnmarshaler(resolver Resolver) Unmarshaler

NewWireUnmarshaler returns a new Unmarshaler for wire.

resolver can be nil if unknown and are only needed for extensions.

func NewYAMLUnmarshaler

func NewYAMLUnmarshaler(resolver Resolver, options ...YAMLUnmarshalerOption) Unmarshaler

NewYAMLUnmarshaler returns a new Unmarshaler for yaml.

resolver can be nil if unknown and are only needed for extensions.

type YAMLMarshalerOption

type YAMLMarshalerOption func(*yamlMarshaler)

YAMLMarshalerOption is an option for a new YAMLMarshaler.

func YAMLMarshalerWithEmitUnpopulated

func YAMLMarshalerWithEmitUnpopulated() YAMLMarshalerOption

YAMLMarshalerWithEmitUnpopulated says to emit unpopulated values

func YAMLMarshalerWithIndent

func YAMLMarshalerWithIndent() YAMLMarshalerOption

YAMLMarshalerWithIndent says to use an indent of two spaces.

func YAMLMarshalerWithUseEnumNumbers

func YAMLMarshalerWithUseEnumNumbers() YAMLMarshalerOption

YAMLMarshalerWithUseEnumNumbers says to use enum numbers.

func YAMLMarshalerWithUseProtoNames

func YAMLMarshalerWithUseProtoNames() YAMLMarshalerOption

YAMLMarshalerWithUseProtoNames says to use proto names.

type YAMLUnmarshalerOption

type YAMLUnmarshalerOption func(*yamlUnmarshaler)

YAMLUnmarshalerOption is an option for a new YAMLUnmarshaler.

func YAMLUnmarshalerWithPath

func YAMLUnmarshalerWithPath(path string) YAMLUnmarshalerOption

YAMLUnmarshalerWithPath says to use the given path.

func YAMLUnmarshalerWithValidator

func YAMLUnmarshalerWithValidator(validator protoyaml.Validator) YAMLUnmarshalerOption

Jump to

Keyboard shortcuts

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