Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var JSONPBFallbackStructTagParser bsoncodec.StructTagParserFunc = func(sf reflect.StructField) (bsoncodec.StructTags, error) { if _, ok := sf.Tag.Lookup("bson"); ok { return bsoncodec.DefaultStructTagParser(sf) } tag, ok := sf.Tag.Lookup("protobuf") if !ok { return bsoncodec.DefaultStructTagParser(sf) } return parseTags(tag, false) }
JSONPBFallbackStructTagParser is the StructTagParser used by the MessageCodec by default. It has the same behavior as bsoncodec.DefaultStructTagParser but will also fallback to parsing the protobuf tag on a field where the bson tag isn't available. In this case, the key will be taken from the json property, or from the name property if there is none.
An example:
type T struct { Name string `protobuf:"bytes,1,opt,name=name,proto3"` // Key is "name" FooBar string `protobuf:"bytes,2,opt,name=foo_bar,json=fooBar,proto3"` // Key is "fooBar" BarFoo string `protobuf:"bytes,3,opt,name=bar_foo,json=barFoo,proto3" bson:"barfoo"` // Key is "barfoo" }
var ProtoNamesFallbackStructTagParser bsoncodec.StructTagParserFunc = func(sf reflect.StructField) (bsoncodec.StructTags, error) { if _, ok := sf.Tag.Lookup("bson"); ok { return bsoncodec.DefaultStructTagParser(sf) } tag, ok := sf.Tag.Lookup("protobuf") if !ok { return bsoncodec.DefaultStructTagParser(sf) } return parseTags(tag, true) }
ProtoNamesFallbackStructTagParser has the same behavior as JSONPBFallbackStructTagParser except it forces the use of the name property as the key when parsing protobuf tags.
var TypeBoolValue = reflect.TypeOf((*wrapperspb.BoolValue)(nil))
BoolValue type.
var TypeBytesValue = reflect.TypeOf((*wrapperspb.BytesValue)(nil))
BytesValue type.
var TypeDoubleValue = reflect.TypeOf((*wrapperspb.DoubleValue)(nil))
DoubleValue type.
var TypeDuration = reflect.TypeOf((*durationpb.Duration)(nil))
Duration type.
var TypeFloatValue = reflect.TypeOf((*wrapperspb.FloatValue)(nil))
FloatValue type.
var TypeInt32Value = reflect.TypeOf((*wrapperspb.Int32Value)(nil))
Int32Value type.
var TypeInt64Value = reflect.TypeOf((*wrapperspb.Int64Value)(nil))
Int64Value type.
Message type.
var TypeStringValue = reflect.TypeOf((*wrapperspb.StringValue)(nil))
StringValue type.
var TypeTimestamp = reflect.TypeOf((*timestamppb.Timestamp)(nil))
Timestamp type.
var TypeUInt32Value = reflect.TypeOf((*wrapperspb.UInt32Value)(nil))
UInt32Value type.
var TypeUInt64Value = reflect.TypeOf((*wrapperspb.UInt64Value)(nil))
UInt64Value type.
Functions ¶
This section is empty.
Types ¶
type BoolValueCodec ¶ added in v0.2.0
type BoolValueCodec struct{}
BoolValueCodec is the Codec used for *wrapperspb.BoolValue values.
func NewBoolValueCodec ¶ added in v0.2.0
func NewBoolValueCodec() *BoolValueCodec
NewBoolValueCodec returns a BoolValueCodec.
func (*BoolValueCodec) DecodeValue ¶ added in v0.2.0
func (c *BoolValueCodec) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, v reflect.Value) error
DecodeValue is the ValueDecoderFunc for *wrapperspb.BoolValue.
func (*BoolValueCodec) EncodeValue ¶ added in v0.2.0
func (c *BoolValueCodec) EncodeValue(ec bsoncodec.EncodeContext, vw bsonrw.ValueWriter, v reflect.Value) error
EncodeValue is the ValueEncoderFunc for *wrapperspb.BoolValue.
type BytesValueCodec ¶ added in v0.2.0
type BytesValueCodec struct{}
BytesValueCodec is the Codec used for *wrapperspb.BytesValue values.
func NewBytesValueCodec ¶ added in v0.2.0
func NewBytesValueCodec() *BytesValueCodec
NewBytesValueCodec returns a BytesValueCodec.
func (*BytesValueCodec) DecodeValue ¶ added in v0.2.0
func (c *BytesValueCodec) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, v reflect.Value) error
DecodeValue is the ValueDecoderFunc for *wrapperspb.BytesValue.
func (*BytesValueCodec) EncodeValue ¶ added in v0.2.0
func (c *BytesValueCodec) EncodeValue(ec bsoncodec.EncodeContext, vw bsonrw.ValueWriter, v reflect.Value) error
EncodeValue is the ValueEncoderFunc for *wrapperspb.BytesValue.
type DoubleValueCodec ¶ added in v0.2.0
type DoubleValueCodec struct{}
DoubleValueCodec is the Codec used for *wrapperspb.DoubleValue values.
func NewDoubleValueCodec ¶ added in v0.2.0
func NewDoubleValueCodec() *DoubleValueCodec
NewDoubleValueCodec returns a DoubleValueCodec.
func (*DoubleValueCodec) DecodeValue ¶ added in v0.2.0
func (c *DoubleValueCodec) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, v reflect.Value) error
DecodeValue is the ValueDecoderFunc for *wrapperspb.DoubleValue.
func (*DoubleValueCodec) EncodeValue ¶ added in v0.2.0
func (c *DoubleValueCodec) EncodeValue(ec bsoncodec.EncodeContext, vw bsonrw.ValueWriter, v reflect.Value) error
EncodeValue is the ValueEncoderFunc for *wrapperspb.DoubleValue.
type DurationCodec ¶ added in v0.3.0
type DurationCodec struct{}
DurationCodec is the Codec used for *durationpb.Duration values.
func NewDurationCodec ¶ added in v0.3.0
func NewDurationCodec() *DurationCodec
NewDurationCodec returns a DurationCodec.
func (*DurationCodec) DecodeValue ¶ added in v0.3.0
func (c *DurationCodec) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, v reflect.Value) error
DecodeValue is the ValueDecoderFunc for *durationpb.Duration.
func (*DurationCodec) EncodeValue ¶ added in v0.3.0
func (c *DurationCodec) EncodeValue(ec bsoncodec.EncodeContext, vw bsonrw.ValueWriter, v reflect.Value) error
EncodeValue is the ValueEncoderFunc for *durationpb.Duration.
type FloatValueCodec ¶ added in v0.2.0
type FloatValueCodec struct{}
FloatValueCodec is the Codec used for *wrapperspb.FloatValue values.
func NewFloatValueCodec ¶ added in v0.2.0
func NewFloatValueCodec() *FloatValueCodec
NewFloatValueCodec returns a FloatValueCodec.
func (*FloatValueCodec) DecodeValue ¶ added in v0.2.0
func (c *FloatValueCodec) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, v reflect.Value) error
DecodeValue is the ValueDecoderFunc for *wrapperspb.FloatValue.
func (*FloatValueCodec) EncodeValue ¶ added in v0.2.0
func (c *FloatValueCodec) EncodeValue(ec bsoncodec.EncodeContext, vw bsonrw.ValueWriter, v reflect.Value) error
EncodeValue is the ValueEncoderFunc for *wrapperspb.FloatValue.
type Int32ValueCodec ¶ added in v0.2.0
type Int32ValueCodec struct{}
Int32ValueCodec is the Codec used for *wrapperspb.Int32Value values.
func NewInt32ValueCodec ¶ added in v0.2.0
func NewInt32ValueCodec() *Int32ValueCodec
NewInt32ValueCodec returns a Int32ValueCodec.
func (*Int32ValueCodec) DecodeValue ¶ added in v0.2.0
func (c *Int32ValueCodec) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, v reflect.Value) error
DecodeValue is the ValueDecoderFunc for *wrapperspb.Int32Value.
func (*Int32ValueCodec) EncodeValue ¶ added in v0.2.0
func (c *Int32ValueCodec) EncodeValue(ec bsoncodec.EncodeContext, vw bsonrw.ValueWriter, v reflect.Value) error
EncodeValue is the ValueEncoderFunc for *wrapperspb.Int32Value.
type Int64ValueCodec ¶ added in v0.2.0
type Int64ValueCodec struct{}
Int64ValueCodec is the Codec used for *wrapperspb.Int64Value values.
func NewInt64ValueCodec ¶ added in v0.2.0
func NewInt64ValueCodec() *Int64ValueCodec
NewInt64ValueCodec returns a Int64ValueCodec.
func (*Int64ValueCodec) DecodeValue ¶ added in v0.2.0
func (c *Int64ValueCodec) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, v reflect.Value) error
DecodeValue is the ValueDecoderFunc for *wrapperspb.Int64Value.
func (*Int64ValueCodec) EncodeValue ¶ added in v0.2.0
func (c *Int64ValueCodec) EncodeValue(ec bsoncodec.EncodeContext, vw bsonrw.ValueWriter, v reflect.Value) error
EncodeValue is the ValueEncoderFunc for *wrapperspb.Int64Value.
type MessageCodec ¶
type MessageCodec struct {
*bsoncodec.StructCodec
}
MessageCodec is the Codec used for proto.Message values.
func NewMessageCodec ¶
func NewMessageCodec(opts ...*protobsonoptions.MessageCodecOptions) *MessageCodec
NewMessageCodec returns a MessageCodec with options opts.
func (*MessageCodec) DecodeValue ¶
func (c *MessageCodec) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, v reflect.Value) error
DecodeValue is the ValueDecoderFunc for proto.Message.
func (*MessageCodec) EncodeValue ¶
func (c *MessageCodec) EncodeValue(ec bsoncodec.EncodeContext, vw bsonrw.ValueWriter, v reflect.Value) error
EncodeValue is the ValueEncoderFunc for proto.Message.
type StringValueCodec ¶ added in v0.2.0
type StringValueCodec struct{}
StringValueCodec is the Codec used for *wrapperspb.StringValue values.
func NewStringValueCodec ¶ added in v0.2.0
func NewStringValueCodec() *StringValueCodec
NewStringValueCodec returns a StringValueCodec.
func (*StringValueCodec) DecodeValue ¶ added in v0.2.0
func (c *StringValueCodec) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, v reflect.Value) error
DecodeValue is the ValueDecoderFunc for *wrapperspb.StringValue.
func (*StringValueCodec) EncodeValue ¶ added in v0.2.0
func (c *StringValueCodec) EncodeValue(ec bsoncodec.EncodeContext, vw bsonrw.ValueWriter, v reflect.Value) error
EncodeValue is the ValueEncoderFunc for *wrapperspb.StringValue.
type TimestampCodec ¶
type TimestampCodec struct{}
TimestampCodec is the Codec used for *timestamppb.Timestamp values.
func NewTimestampCodec ¶
func NewTimestampCodec() *TimestampCodec
NewTimestampCodec returns a TimestampCodec.
func (*TimestampCodec) DecodeValue ¶
func (c *TimestampCodec) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, v reflect.Value) error
DecodeValue is the ValueDecoderFunc for *timestamppb.Timestamp.
func (*TimestampCodec) EncodeValue ¶
func (c *TimestampCodec) EncodeValue(ec bsoncodec.EncodeContext, vw bsonrw.ValueWriter, v reflect.Value) error
EncodeValue is the ValueEncoderFunc for *timestamppb.Timestamp.
type UInt32ValueCodec ¶ added in v0.2.0
type UInt32ValueCodec struct{}
UInt32ValueCodec is the Codec used for *wrapperspb.UInt32Value values.
func NewUInt32ValueCodec ¶ added in v0.2.0
func NewUInt32ValueCodec() *UInt32ValueCodec
NewUInt32ValueCodec returns a UInt32ValueCodec.
func (*UInt32ValueCodec) DecodeValue ¶ added in v0.2.0
func (vc *UInt32ValueCodec) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, v reflect.Value) error
DecodeValue is the ValueDecoderFunc for *wrapperspb.UInt32Value.
func (*UInt32ValueCodec) EncodeValue ¶ added in v0.2.0
func (vc *UInt32ValueCodec) EncodeValue(ec bsoncodec.EncodeContext, vw bsonrw.ValueWriter, v reflect.Value) error
EncodeValue is the ValueEncoderFunc for *wrapperspb.UInt32Value.
type UInt64ValueCodec ¶ added in v0.2.0
type UInt64ValueCodec struct{}
UInt64ValueCodec is the Codec used for *wrapperspb.UInt64Value values.
func NewUInt64ValueCodec ¶ added in v0.2.0
func NewUInt64ValueCodec() *UInt64ValueCodec
NewUInt64ValueCodec returns a UInt64ValueCodec.
func (*UInt64ValueCodec) DecodeValue ¶ added in v0.2.0
func (c *UInt64ValueCodec) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, v reflect.Value) error
DecodeValue is the ValueDecoderFunc for *wrapperspb.UInt64Value.
func (*UInt64ValueCodec) EncodeValue ¶ added in v0.2.0
func (c *UInt64ValueCodec) EncodeValue(ec bsoncodec.EncodeContext, vw bsonrw.ValueWriter, v reflect.Value) error
EncodeValue is the ValueEncoderFunc for *wrapperspb.UInt64Value.