protobson

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BsonPBRegistry = NewBsonPBRegistryBuilder().Build()

BsonPBRegistry that provide protojson compatible BSON encoding.

View Source
var ErrUnknownField = errors.New("unknown field")

Functions

func NewBsonPBRegistryBuilder

func NewBsonPBRegistryBuilder() *bsoncodec.RegistryBuilder

Types

type ProtoEnumCodec

type ProtoEnumCodec struct {

	// UseEnumNumbers emits enum values as numbers.
	UseEnumNumbers bool
	// contains filtered or unexported fields
}

ProtoEnumCodec is the Codec used for struct values.

func NewProtoEnumCodec

func NewProtoEnumCodec() *ProtoEnumCodec

NewProtoEnumCodec returns a ProtoEnumCodec that uses p for struct tag parsing.

func (*ProtoEnumCodec) DecodeValue

DecodeValue implements the Codec interface. By default, map types in val will not be cleared. If a map has existing key/value pairs, it will be extended with the new ones from vr. For slices, the decoder will set the length of the slice to zero and append all elements. The underlying array will not be cleared.

func (*ProtoEnumCodec) EncodeValue

EncodeValue handles encoding generic struct types.

type ProtoMessageCodec

type ProtoMessageCodec struct {

	// AllowPartial allows messages that have missing required fields to marshal
	// without returning an error. If AllowPartial is false (the default),
	// Marshal will return error if there are any missing required fields.
	AllowMarshalPartial bool

	// If AllowPartial is set, input for messages that will result in missing
	// required fields will not return an error.
	AllowUnmarshalPartial bool

	// UseProtoNames uses proto field name instead of lowerCamelCase name in JSON
	// field names.
	UseProtoNames bool

	// UseEnumNumbers emits enum values as numbers.
	UseEnumNumbers bool

	// If DiscardUnknown is set, unknown fields are ignored.
	DiscardUnknown bool

	// Resolver is used for looking up types when expanding google.protobuf.Any
	// messages. If nil, this defaults to using protoregistry.GlobalTypes.
	Resolver interface {
		protoregistry.ExtensionTypeResolver
		protoregistry.MessageTypeResolver
	}
	// contains filtered or unexported fields
}

ProtoMessageCodec is the Codec used for the protoreflect.ProtoMessage (aka proto.Message) values.

func NewProtoMessageCodec

func NewProtoMessageCodec() *ProtoMessageCodec

NewProtoMessageCodec returns a ProtoMessageCodec that uses p for struct tag parsing.

func (*ProtoMessageCodec) DecodeValue

DecodeValue implements the Codec interface. By default, map types in val will not be cleared. If a map has existing key/value pairs, it will be extended with the new ones from vr. For slices, the decoder will set the length of the slice to zero and append all elements. The underlying array will not be cleared.

func (*ProtoMessageCodec) EncodeValue

EncodeValue handles encoding generic struct types.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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