wrapper

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: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWrapperEmbeddedField = errors.New(
	"wrapper messages should not have embedded fields",
)
View Source
var ErrWrapperMessageType = errors.New("wrapper codec expected pointer to struct")
View Source
var ErrWrapperPublicFieldCount = errors.New(
	"wrapper expected to have exactly 1 public field",
)

Functions

This section is empty.

Types

type ProtoWrapperCodec

type ProtoWrapperCodec struct {
	FieldIndex int
}

Codec for encoding gRPC wrappers.BoolValue, which exposes an API for having nullable boolean values.

func MustWrapperCodec

func MustWrapperCodec(protoMessage proto.Message) ProtoWrapperCodec

func NewWrapperCodec

func NewWrapperCodec(protoMessage interface{}) (ProtoWrapperCodec, error)

Builds the wrapper codec for a given proto message.

Wrapper messages must:

  • Have exactly 1 non-embedded public field. This field's value will be extracted and marshalled as the bson value.

func (ProtoWrapperCodec) DecodeValue

func (codec ProtoWrapperCodec) DecodeValue(
	context bsoncodec.DecodeContext, reader bsonrw.ValueReader, value reflect.Value,
) error

func (ProtoWrapperCodec) EncodeValue

func (codec ProtoWrapperCodec) EncodeValue(
	context bsoncodec.EncodeContext, writer bsonrw.ValueWriter, value reflect.Value,
) error

Jump to

Keyboard shortcuts

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