| 1 | // Copyright (C) MongoDB, Inc. 2017-present. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | // not use this file except in compliance with the License. You may obtain |
| 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | |
| 7 | package bsonoptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/ |
| 8 | |
| 9 | // ByteSliceCodecOptions represents all possible options for byte slice encoding and decoding. |
| 10 | // |
| 11 | // Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal |
| 12 | // and unmarshal behavior instead. |
| 13 | type ByteSliceCodecOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/ByteSliceCodecOptions# struct { |
| 14 | EncodeNilAsEmptyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/ByteSliceCodecOptions#EncodeNilAsEmpty. *bool // Specifies if a nil byte slice should encode as an empty binary instead of null. Defaults to false. |
| 15 | } |
| 16 | |
| 17 | // ByteSliceCodec creates a new *ByteSliceCodecOptions |
| 18 | // |
| 19 | // Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal |
| 20 | // and unmarshal behavior instead. |
| 21 | func ByteSliceCodecscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/ByteSliceCodec().() *ByteSliceCodecOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/ByteSliceCodecOptions# { |
| 22 | return &ByteSliceCodecOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/ByteSliceCodecOptions#{} |
| 23 | } |
| 24 | |
| 25 | // SetEncodeNilAsEmpty specifies if a nil byte slice should encode as an empty binary instead of null. Defaults to false. |
| 26 | // |
| 27 | // Deprecated: Use [go.mongodb.org/mongo-driver/bson.Encoder.NilByteSliceAsEmpty] instead. |
| 28 | func (bs *ByteSliceCodecOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/ByteSliceCodecOptions#) SetEncodeNilAsEmptyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/ByteSliceCodecOptions#SetEncodeNilAsEmpty().(b bool) *ByteSliceCodecOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/ByteSliceCodecOptions# { |
| 29 | bs.EncodeNilAsEmptyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/ByteSliceCodecOptions#EncodeNilAsEmpty. = &b |
| 30 | return bs |
| 31 | } |
| 32 | |
| 33 | // MergeByteSliceCodecOptions combines the given *ByteSliceCodecOptions into a single *ByteSliceCodecOptions in a last one wins fashion. |
| 34 | // |
| 35 | // Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create a |
| 36 | // single options struct instead. |
| 37 | func MergeByteSliceCodecOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MergeByteSliceCodecOptions().(opts ...*ByteSliceCodecOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/ByteSliceCodecOptions#) *ByteSliceCodecOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/ByteSliceCodecOptions# { |
| 38 | bs := ByteSliceCodecscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/ByteSliceCodec().() |
| 39 | for _, opt := range opts { |
| 40 | if opt == nil { |
| 41 | continue |
| 42 | } |
| 43 | if opt.EncodeNilAsEmptyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/ByteSliceCodecOptions#EncodeNilAsEmpty. != nil { |
| 44 | bs.EncodeNilAsEmptyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/ByteSliceCodecOptions#EncodeNilAsEmpty. = opt.EncodeNilAsEmptyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/ByteSliceCodecOptions#EncodeNilAsEmpty. |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | return bs |
| 49 | } |