Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var BsonPBRegistry = NewBsonPBRegistryBuilder().Build()
BsonPBRegistry that provide protojson compatible BSON encoding.
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 ¶
func (sc *ProtoEnumCodec) DecodeValue(r bsoncodec.DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error
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 ¶
func (sc *ProtoEnumCodec) EncodeValue(r bsoncodec.EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error
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 ¶
func (sc *ProtoMessageCodec) DecodeValue(r bsoncodec.DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error
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 ¶
func (sc *ProtoMessageCodec) EncodeValue(r bsoncodec.EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error
EncodeValue handles encoding generic struct types.