oneof

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWrongOneOfInterface = errors.New("oneof interface not implemented")

Functions

This section is empty.

Types

type CodecBuilder

type CodecBuilder struct {
	// contains filtered or unexported fields
}

func CodecBuildersForMessage

func CodecBuildersForMessage(
	message proto.Message, elementInfo []*ElementInfo,
) ([]*CodecBuilder, error)

func NewCodecBuilder

func NewCodecBuilder() *CodecBuilder

func (*CodecBuilder) AddConcrete

func (builder *CodecBuilder) AddConcrete(
	oneOfType reflect.Type, bsonType bsontype.Type, binaryType byte,
) error

Register a concrete one of type and the bson type it is encoded to. We don't know what other codecs are in the registry, so to properly round-trip a one-of field we need to create a 1-1 mapping of the wrapper type and it's bson encoded type, except for the special case of message types that encoded to embedded docs, since we can add a field with the proto message type.

func (*CodecBuilder) AutoAddConcrete

func (builder *CodecBuilder) AutoAddConcrete(
	oneOfTypes ...reflect.Type,
) error

Try to automatically deduce the encoding / decoding mapping of the wrapper types.

func (*CodecBuilder) Register

func (builder *CodecBuilder) Register(
	registryBuilder *bsoncodec.RegistryBuilder,
) error

type ConcreteTypeCodecInfo

type ConcreteTypeCodecInfo struct {
	ConcreteType reflect.Type
	Codec        bsoncodec.ValueCodec
}

type ElementInfo

type ElementInfo struct {
	InnerGoType   reflect.Type
	BsonType      bsontype.Type
	BinarySubType byte
}

Jump to

Keyboard shortcuts

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