protobson

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCerealRegistryBuilder

func NewCerealRegistryBuilder(opts *Opts) (*bsoncodec.RegistryBuilder, error)

func RegisterCerealCodecs

func RegisterCerealCodecs(builder *bsoncodec.RegistryBuilder, opts *Opts) error

Register a the cereal codecs onto a registry builder.

Types

type Opts

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

Holds options for registering codecs.

func NewMongoOpts

func NewMongoOpts() *Opts

Create a new mongo opts object with default values.

func (*Opts) WithAddDefaultCodecs

func (opts *Opts) WithAddDefaultCodecs(add bool) *Opts

Whether to add the default mongo codecs to the registry. Default: true.

func (*Opts) WithCustomWrappers

func (opts *Opts) WithCustomWrappers(wrapperMessages ...proto.Message) *Opts

Add a new wrapper type (as wrapperspb.StringValue) that is not one of protoCereal's default wrapper codecs.

func (*Opts) WithEnumStrings

func (opts *Opts) WithEnumStrings(enable bool) *Opts

Whether to add the default mongo codecs to the registry. Default: true.

func (*Opts) WithOneOfElementMapping

func (opts *Opts) WithOneOfElementMapping(
	innerValue interface{}, bsonType bsontype.Type, binarySubType byte,
) *Opts

Add a proto oneof element type and it's bson mapping for generating. This is only needed if a oneof element's type cannot be automatically inferred (you have registered a custom encoder for it.)

func (*Opts) WithOneOfFields

func (opts *Opts) WithOneOfFields(messages ...proto.Message) *Opts

Extract one-of fields from these message types and register their encoders / decoders with the registry.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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