Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReparseExtensions ¶ added in v1.43.0
func ReparseExtensions(resolver Resolver, reflectMessage protoreflect.Message) error
ReparseExtensions uses the given resolver to parse any unrecognized fields in the given reflectMessage as well as re-parse any extensions.
Types ¶
type JSONMarshalerOption ¶ added in v1.20.0
type JSONMarshalerOption func(*jsonMarshaler)
JSONMarshalerOption is an option for a new JSONMarshaler.
func JSONMarshalerWithEmitUnpopulated ¶ added in v1.20.0
func JSONMarshalerWithEmitUnpopulated() JSONMarshalerOption
JSONMarshalerWithEmitUnpopulated says to emit unpopulated values
func JSONMarshalerWithIndent ¶ added in v1.20.0
func JSONMarshalerWithIndent() JSONMarshalerOption
JSONMarshalerWithIndent says to use an indent of two spaces.
func JSONMarshalerWithUseEnumNumbers ¶ added in v1.29.0
func JSONMarshalerWithUseEnumNumbers() JSONMarshalerOption
JSONMarshalerWithUseEnumNumbers says to use enum numbers.
func JSONMarshalerWithUseProtoNames ¶ added in v1.20.0
func JSONMarshalerWithUseProtoNames() JSONMarshalerOption
JSONMarshalerWithUseProtoNames says to use proto names.
type JSONUnmarshalerOption ¶ added in v1.28.1
type JSONUnmarshalerOption func(*jsonUnmarshaler)
JSONUnmarshalerOption is an option for a new JSONUnmarshaler.
func JSONUnmarshalerWithDisallowUnknown ¶ added in v1.28.1
func JSONUnmarshalerWithDisallowUnknown() JSONUnmarshalerOption
JSONUnmarshalerWithDisallowUnknown says to disallow unrecognized fields.
type Marshaler ¶
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. If the resolver is nil, EmptyResolver will be used.
func NewTxtpbMarshaler ¶ added in v1.25.0
NewTxtpbMarshaler returns a new Marshaler for txtpb.
If the resolver is nil, EmptyResolver will be used.
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 ¶ added in v1.29.0
func NewYAMLMarshaler(resolver Resolver, options ...YAMLMarshalerOption) Marshaler
NewYAMLMarshaler returns a new Marshaler for YAML.
If the resolver is nil, EmptyResolver will be used.
type Resolver ¶
type Resolver interface { protodesc.Resolver protoregistry.ExtensionTypeResolver protoregistry.MessageTypeResolver FindEnumByName(enum protoreflect.FullName) (protoreflect.EnumType, error) }
Resolver can resolve files, messages, enums, and extensions.
var EmptyResolver Resolver = emptyResolver{}
EmptyResolver is a resolver that never resolves any descriptors. All methods will return (nil, NotFound).
func CombineResolvers ¶ added in v1.28.1
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 ¶ added in v1.10.0
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 ¶
Unmarshaler unmarshals Messages.
func NewJSONUnmarshaler ¶
func NewJSONUnmarshaler(resolver Resolver, options ...JSONUnmarshalerOption) Unmarshaler
NewJSONUnmarshaler returns a new Unmarshaler for json.
If the resolver is nil, EmptyResolver will be used.
func NewTxtpbUnmarshaler ¶ added in v1.25.0
func NewTxtpbUnmarshaler(resolver Resolver) Unmarshaler
NewTxtpbUnmarshaler returns a new Unmarshaler for txtpb.
If the resolver is nil, EmptyResolver will be used.
func NewWireUnmarshaler ¶
func NewWireUnmarshaler(resolver Resolver) Unmarshaler
NewWireUnmarshaler returns a new Unmarshaler for wire.
If the resolver is nil, EmptyResolver will be used.
func NewYAMLUnmarshaler ¶ added in v1.29.0
func NewYAMLUnmarshaler(resolver Resolver, options ...YAMLUnmarshalerOption) Unmarshaler
NewYAMLUnmarshaler returns a new Unmarshaler for yaml.
If the resolver is nil, EmptyResolver will be used.
type YAMLMarshalerOption ¶ added in v1.29.0
type YAMLMarshalerOption func(*yamlMarshaler)
YAMLMarshalerOption is an option for a new YAMLMarshaler.
func YAMLMarshalerWithEmitUnpopulated ¶ added in v1.29.0
func YAMLMarshalerWithEmitUnpopulated() YAMLMarshalerOption
YAMLMarshalerWithEmitUnpopulated says to emit unpopulated values
func YAMLMarshalerWithIndent ¶ added in v1.29.0
func YAMLMarshalerWithIndent() YAMLMarshalerOption
YAMLMarshalerWithIndent says to use an indent of two spaces.
func YAMLMarshalerWithUseEnumNumbers ¶ added in v1.29.0
func YAMLMarshalerWithUseEnumNumbers() YAMLMarshalerOption
YAMLMarshalerWithUseEnumNumbers says to use enum numbers.
func YAMLMarshalerWithUseProtoNames ¶ added in v1.29.0
func YAMLMarshalerWithUseProtoNames() YAMLMarshalerOption
YAMLMarshalerWithUseProtoNames says to use proto names.
type YAMLUnmarshalerOption ¶ added in v1.29.0
type YAMLUnmarshalerOption func(*yamlUnmarshaler)
YAMLUnmarshalerOption is an option for a new YAMLUnmarshaler.
func YAMLUnmarshalerWithPath ¶ added in v1.29.0
func YAMLUnmarshalerWithPath(path string) YAMLUnmarshalerOption
YAMLUnmarshalerWithPath says to use the given path.
func YAMLUnmarshalerWithValidator ¶ added in v1.29.0
func YAMLUnmarshalerWithValidator(validator protoyaml.Validator) YAMLUnmarshalerOption