summaryrefslogtreecommitdiff
path: root/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/go.mongodb.org/mongo-driver/bson/bsonoptions')
-rw-r--r--vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/byte_slice_codec_options.go38
-rw-r--r--vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/doc.go8
-rw-r--r--vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/empty_interface_codec_options.go38
-rw-r--r--vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/map_codec_options.go67
-rw-r--r--vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/slice_codec_options.go38
-rw-r--r--vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/string_codec_options.go41
-rw-r--r--vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/struct_codec_options.go87
-rw-r--r--vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/time_codec_options.go38
-rw-r--r--vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/uint_codec_options.go38
9 files changed, 393 insertions, 0 deletions
diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/byte_slice_codec_options.go b/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/byte_slice_codec_options.go
new file mode 100644
index 000000000..b1256a4dc
--- /dev/null
+++ b/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/byte_slice_codec_options.go
@@ -0,0 +1,38 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package bsonoptions
+
+// ByteSliceCodecOptions represents all possible options for byte slice encoding and decoding.
+type ByteSliceCodecOptions struct {
+ EncodeNilAsEmpty *bool // Specifies if a nil byte slice should encode as an empty binary instead of null. Defaults to false.
+}
+
+// ByteSliceCodec creates a new *ByteSliceCodecOptions
+func ByteSliceCodec() *ByteSliceCodecOptions {
+ return &ByteSliceCodecOptions{}
+}
+
+// SetEncodeNilAsEmpty specifies if a nil byte slice should encode as an empty binary instead of null. Defaults to false.
+func (bs *ByteSliceCodecOptions) SetEncodeNilAsEmpty(b bool) *ByteSliceCodecOptions {
+ bs.EncodeNilAsEmpty = &b
+ return bs
+}
+
+// MergeByteSliceCodecOptions combines the given *ByteSliceCodecOptions into a single *ByteSliceCodecOptions in a last one wins fashion.
+func MergeByteSliceCodecOptions(opts ...*ByteSliceCodecOptions) *ByteSliceCodecOptions {
+ bs := ByteSliceCodec()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.EncodeNilAsEmpty != nil {
+ bs.EncodeNilAsEmpty = opt.EncodeNilAsEmpty
+ }
+ }
+
+ return bs
+}
diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/doc.go b/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/doc.go
new file mode 100644
index 000000000..c40973c8d
--- /dev/null
+++ b/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/doc.go
@@ -0,0 +1,8 @@
+// Copyright (C) MongoDB, Inc. 2022-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+// Package bsonoptions defines the optional configurations for the BSON codecs.
+package bsonoptions
diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/empty_interface_codec_options.go b/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/empty_interface_codec_options.go
new file mode 100644
index 000000000..6caaa000e
--- /dev/null
+++ b/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/empty_interface_codec_options.go
@@ -0,0 +1,38 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package bsonoptions
+
+// EmptyInterfaceCodecOptions represents all possible options for interface{} encoding and decoding.
+type EmptyInterfaceCodecOptions struct {
+ DecodeBinaryAsSlice *bool // Specifies if Old and Generic type binarys should default to []slice instead of primitive.Binary. Defaults to false.
+}
+
+// EmptyInterfaceCodec creates a new *EmptyInterfaceCodecOptions
+func EmptyInterfaceCodec() *EmptyInterfaceCodecOptions {
+ return &EmptyInterfaceCodecOptions{}
+}
+
+// SetDecodeBinaryAsSlice specifies if Old and Generic type binarys should default to []slice instead of primitive.Binary. Defaults to false.
+func (e *EmptyInterfaceCodecOptions) SetDecodeBinaryAsSlice(b bool) *EmptyInterfaceCodecOptions {
+ e.DecodeBinaryAsSlice = &b
+ return e
+}
+
+// MergeEmptyInterfaceCodecOptions combines the given *EmptyInterfaceCodecOptions into a single *EmptyInterfaceCodecOptions in a last one wins fashion.
+func MergeEmptyInterfaceCodecOptions(opts ...*EmptyInterfaceCodecOptions) *EmptyInterfaceCodecOptions {
+ e := EmptyInterfaceCodec()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.DecodeBinaryAsSlice != nil {
+ e.DecodeBinaryAsSlice = opt.DecodeBinaryAsSlice
+ }
+ }
+
+ return e
+}
diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/map_codec_options.go b/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/map_codec_options.go
new file mode 100644
index 000000000..7a6a880b8
--- /dev/null
+++ b/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/map_codec_options.go
@@ -0,0 +1,67 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package bsonoptions
+
+// MapCodecOptions represents all possible options for map encoding and decoding.
+type MapCodecOptions struct {
+ DecodeZerosMap *bool // Specifies if the map should be zeroed before decoding into it. Defaults to false.
+ EncodeNilAsEmpty *bool // Specifies if a nil map should encode as an empty document instead of null. Defaults to false.
+ // Specifies how keys should be handled. If false, the behavior matches encoding/json, where the encoding key type must
+ // either be a string, an integer type, or implement bsoncodec.KeyMarshaler and the decoding key type must either be a
+ // string, an integer type, or implement bsoncodec.KeyUnmarshaler. If true, keys are encoded with fmt.Sprint() and the
+ // encoding key type must be a string, an integer type, or a float. If true, the use of Stringer will override
+ // TextMarshaler/TextUnmarshaler. Defaults to false.
+ EncodeKeysWithStringer *bool
+}
+
+// MapCodec creates a new *MapCodecOptions
+func MapCodec() *MapCodecOptions {
+ return &MapCodecOptions{}
+}
+
+// SetDecodeZerosMap specifies if the map should be zeroed before decoding into it. Defaults to false.
+func (t *MapCodecOptions) SetDecodeZerosMap(b bool) *MapCodecOptions {
+ t.DecodeZerosMap = &b
+ return t
+}
+
+// SetEncodeNilAsEmpty specifies if a nil map should encode as an empty document instead of null. Defaults to false.
+func (t *MapCodecOptions) SetEncodeNilAsEmpty(b bool) *MapCodecOptions {
+ t.EncodeNilAsEmpty = &b
+ return t
+}
+
+// SetEncodeKeysWithStringer specifies how keys should be handled. If false, the behavior matches encoding/json, where the
+// encoding key type must either be a string, an integer type, or implement bsoncodec.KeyMarshaler and the decoding key
+// type must either be a string, an integer type, or implement bsoncodec.KeyUnmarshaler. If true, keys are encoded with
+// fmt.Sprint() and the encoding key type must be a string, an integer type, or a float. If true, the use of Stringer
+// will override TextMarshaler/TextUnmarshaler. Defaults to false.
+func (t *MapCodecOptions) SetEncodeKeysWithStringer(b bool) *MapCodecOptions {
+ t.EncodeKeysWithStringer = &b
+ return t
+}
+
+// MergeMapCodecOptions combines the given *MapCodecOptions into a single *MapCodecOptions in a last one wins fashion.
+func MergeMapCodecOptions(opts ...*MapCodecOptions) *MapCodecOptions {
+ s := MapCodec()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.DecodeZerosMap != nil {
+ s.DecodeZerosMap = opt.DecodeZerosMap
+ }
+ if opt.EncodeNilAsEmpty != nil {
+ s.EncodeNilAsEmpty = opt.EncodeNilAsEmpty
+ }
+ if opt.EncodeKeysWithStringer != nil {
+ s.EncodeKeysWithStringer = opt.EncodeKeysWithStringer
+ }
+ }
+
+ return s
+}
diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/slice_codec_options.go b/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/slice_codec_options.go
new file mode 100644
index 000000000..ef965e4b4
--- /dev/null
+++ b/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/slice_codec_options.go
@@ -0,0 +1,38 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package bsonoptions
+
+// SliceCodecOptions represents all possible options for slice encoding and decoding.
+type SliceCodecOptions struct {
+ EncodeNilAsEmpty *bool // Specifies if a nil slice should encode as an empty array instead of null. Defaults to false.
+}
+
+// SliceCodec creates a new *SliceCodecOptions
+func SliceCodec() *SliceCodecOptions {
+ return &SliceCodecOptions{}
+}
+
+// SetEncodeNilAsEmpty specifies if a nil slice should encode as an empty array instead of null. Defaults to false.
+func (s *SliceCodecOptions) SetEncodeNilAsEmpty(b bool) *SliceCodecOptions {
+ s.EncodeNilAsEmpty = &b
+ return s
+}
+
+// MergeSliceCodecOptions combines the given *SliceCodecOptions into a single *SliceCodecOptions in a last one wins fashion.
+func MergeSliceCodecOptions(opts ...*SliceCodecOptions) *SliceCodecOptions {
+ s := SliceCodec()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.EncodeNilAsEmpty != nil {
+ s.EncodeNilAsEmpty = opt.EncodeNilAsEmpty
+ }
+ }
+
+ return s
+}
diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/string_codec_options.go b/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/string_codec_options.go
new file mode 100644
index 000000000..65964f420
--- /dev/null
+++ b/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/string_codec_options.go
@@ -0,0 +1,41 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package bsonoptions
+
+var defaultDecodeOIDAsHex = true
+
+// StringCodecOptions represents all possible options for string encoding and decoding.
+type StringCodecOptions struct {
+ DecodeObjectIDAsHex *bool // Specifies if we should decode ObjectID as the hex value. Defaults to true.
+}
+
+// StringCodec creates a new *StringCodecOptions
+func StringCodec() *StringCodecOptions {
+ return &StringCodecOptions{}
+}
+
+// SetDecodeObjectIDAsHex specifies if object IDs should be decoded as their hex representation. If false, a string made
+// from the raw object ID bytes will be used. Defaults to true.
+func (t *StringCodecOptions) SetDecodeObjectIDAsHex(b bool) *StringCodecOptions {
+ t.DecodeObjectIDAsHex = &b
+ return t
+}
+
+// MergeStringCodecOptions combines the given *StringCodecOptions into a single *StringCodecOptions in a last one wins fashion.
+func MergeStringCodecOptions(opts ...*StringCodecOptions) *StringCodecOptions {
+ s := &StringCodecOptions{&defaultDecodeOIDAsHex}
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.DecodeObjectIDAsHex != nil {
+ s.DecodeObjectIDAsHex = opt.DecodeObjectIDAsHex
+ }
+ }
+
+ return s
+}
diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/struct_codec_options.go b/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/struct_codec_options.go
new file mode 100644
index 000000000..78d1dd866
--- /dev/null
+++ b/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/struct_codec_options.go
@@ -0,0 +1,87 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package bsonoptions
+
+var defaultOverwriteDuplicatedInlinedFields = true
+
+// StructCodecOptions represents all possible options for struct encoding and decoding.
+type StructCodecOptions struct {
+ DecodeZeroStruct *bool // Specifies if structs should be zeroed before decoding into them. Defaults to false.
+ DecodeDeepZeroInline *bool // Specifies if structs should be recursively zeroed when a inline value is decoded. Defaults to false.
+ EncodeOmitDefaultStruct *bool // Specifies if default structs should be considered empty by omitempty. Defaults to false.
+ AllowUnexportedFields *bool // Specifies if unexported fields should be marshaled/unmarshaled. Defaults to false.
+ OverwriteDuplicatedInlinedFields *bool // Specifies if fields in inlined structs can be overwritten by higher level struct fields with the same key. Defaults to true.
+}
+
+// StructCodec creates a new *StructCodecOptions
+func StructCodec() *StructCodecOptions {
+ return &StructCodecOptions{}
+}
+
+// SetDecodeZeroStruct specifies if structs should be zeroed before decoding into them. Defaults to false.
+func (t *StructCodecOptions) SetDecodeZeroStruct(b bool) *StructCodecOptions {
+ t.DecodeZeroStruct = &b
+ return t
+}
+
+// SetDecodeDeepZeroInline specifies if structs should be zeroed before decoding into them. Defaults to false.
+func (t *StructCodecOptions) SetDecodeDeepZeroInline(b bool) *StructCodecOptions {
+ t.DecodeDeepZeroInline = &b
+ return t
+}
+
+// SetEncodeOmitDefaultStruct specifies if default structs should be considered empty by omitempty. A default struct has all
+// its values set to their default value. Defaults to false.
+func (t *StructCodecOptions) SetEncodeOmitDefaultStruct(b bool) *StructCodecOptions {
+ t.EncodeOmitDefaultStruct = &b
+ return t
+}
+
+// SetOverwriteDuplicatedInlinedFields specifies if inlined struct fields can be overwritten by higher level struct fields with the
+// same bson key. When true and decoding, values will be written to the outermost struct with a matching key, and when
+// encoding, keys will have the value of the top-most matching field. When false, decoding and encoding will error if
+// there are duplicate keys after the struct is inlined. Defaults to true.
+func (t *StructCodecOptions) SetOverwriteDuplicatedInlinedFields(b bool) *StructCodecOptions {
+ t.OverwriteDuplicatedInlinedFields = &b
+ return t
+}
+
+// SetAllowUnexportedFields specifies if unexported fields should be marshaled/unmarshaled. Defaults to false.
+func (t *StructCodecOptions) SetAllowUnexportedFields(b bool) *StructCodecOptions {
+ t.AllowUnexportedFields = &b
+ return t
+}
+
+// MergeStructCodecOptions combines the given *StructCodecOptions into a single *StructCodecOptions in a last one wins fashion.
+func MergeStructCodecOptions(opts ...*StructCodecOptions) *StructCodecOptions {
+ s := &StructCodecOptions{
+ OverwriteDuplicatedInlinedFields: &defaultOverwriteDuplicatedInlinedFields,
+ }
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+
+ if opt.DecodeZeroStruct != nil {
+ s.DecodeZeroStruct = opt.DecodeZeroStruct
+ }
+ if opt.DecodeDeepZeroInline != nil {
+ s.DecodeDeepZeroInline = opt.DecodeDeepZeroInline
+ }
+ if opt.EncodeOmitDefaultStruct != nil {
+ s.EncodeOmitDefaultStruct = opt.EncodeOmitDefaultStruct
+ }
+ if opt.OverwriteDuplicatedInlinedFields != nil {
+ s.OverwriteDuplicatedInlinedFields = opt.OverwriteDuplicatedInlinedFields
+ }
+ if opt.AllowUnexportedFields != nil {
+ s.AllowUnexportedFields = opt.AllowUnexportedFields
+ }
+ }
+
+ return s
+}
diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/time_codec_options.go b/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/time_codec_options.go
new file mode 100644
index 000000000..13496d121
--- /dev/null
+++ b/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/time_codec_options.go
@@ -0,0 +1,38 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package bsonoptions
+
+// TimeCodecOptions represents all possible options for time.Time encoding and decoding.
+type TimeCodecOptions struct {
+ UseLocalTimeZone *bool // Specifies if we should decode into the local time zone. Defaults to false.
+}
+
+// TimeCodec creates a new *TimeCodecOptions
+func TimeCodec() *TimeCodecOptions {
+ return &TimeCodecOptions{}
+}
+
+// SetUseLocalTimeZone specifies if we should decode into the local time zone. Defaults to false.
+func (t *TimeCodecOptions) SetUseLocalTimeZone(b bool) *TimeCodecOptions {
+ t.UseLocalTimeZone = &b
+ return t
+}
+
+// MergeTimeCodecOptions combines the given *TimeCodecOptions into a single *TimeCodecOptions in a last one wins fashion.
+func MergeTimeCodecOptions(opts ...*TimeCodecOptions) *TimeCodecOptions {
+ t := TimeCodec()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.UseLocalTimeZone != nil {
+ t.UseLocalTimeZone = opt.UseLocalTimeZone
+ }
+ }
+
+ return t
+}
diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/uint_codec_options.go b/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/uint_codec_options.go
new file mode 100644
index 000000000..e08b7f192
--- /dev/null
+++ b/vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/uint_codec_options.go
@@ -0,0 +1,38 @@
+// Copyright (C) MongoDB, Inc. 2017-present.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+package bsonoptions
+
+// UIntCodecOptions represents all possible options for uint encoding and decoding.
+type UIntCodecOptions struct {
+ EncodeToMinSize *bool // Specifies if all uints except uint64 should be decoded to minimum size bsontype. Defaults to false.
+}
+
+// UIntCodec creates a new *UIntCodecOptions
+func UIntCodec() *UIntCodecOptions {
+ return &UIntCodecOptions{}
+}
+
+// SetEncodeToMinSize specifies if all uints except uint64 should be decoded to minimum size bsontype. Defaults to false.
+func (u *UIntCodecOptions) SetEncodeToMinSize(b bool) *UIntCodecOptions {
+ u.EncodeToMinSize = &b
+ return u
+}
+
+// MergeUIntCodecOptions combines the given *UIntCodecOptions into a single *UIntCodecOptions in a last one wins fashion.
+func MergeUIntCodecOptions(opts ...*UIntCodecOptions) *UIntCodecOptions {
+ u := UIntCodec()
+ for _, opt := range opts {
+ if opt == nil {
+ continue
+ }
+ if opt.EncodeToMinSize != nil {
+ u.EncodeToMinSize = opt.EncodeToMinSize
+ }
+ }
+
+ return u
+}