@@ -160,21 +160,19 @@ func (fn ValueDecoderFunc) DecodeValue(dc DecodeContext, vr bsonrw.ValueReader,
160
160
return fn (dc , vr , val )
161
161
}
162
162
163
- // typeDecoder is the interface implemented by types that can handle the decoding of a value by
163
+ // typeDecoder is the interface implemented by types that can handle the decoding of a value given its type.
164
164
type typeDecoder interface {
165
165
decodeType (DecodeContext , bsonrw.ValueReader , reflect.Type ) (reflect.Value , error )
166
166
}
167
167
168
- // typeDecoderFunc is an adapter function that allows a function with the correct signature to be
169
- // used as a TypeDecoder.
168
+ // typeDecoderFunc is an adapter function that allows a function with the correct signature to be used as a typeDecoder.
170
169
type typeDecoderFunc func (DecodeContext , bsonrw.ValueReader , reflect.Type ) (reflect.Value , error )
171
170
172
171
func (fn typeDecoderFunc ) decodeType (dc DecodeContext , vr bsonrw.ValueReader , t reflect.Type ) (reflect.Value , error ) {
173
172
return fn (dc , vr , t )
174
173
}
175
174
176
- // ValueTypeDecoderFunc is an adapter struct that allows two functions with the correct signature
177
- // to be used as a ValueTypeDecoder.
175
+ // decodeAdapter allows two functions with the correct signatures to be used as both a ValueDecoder and typeDecoder.
178
176
type decodeAdapter struct {
179
177
ValueDecoderFunc
180
178
typeDecoderFunc
@@ -183,8 +181,8 @@ type decodeAdapter struct {
183
181
var _ ValueDecoder = decodeAdapter {}
184
182
var _ typeDecoder = decodeAdapter {}
185
183
186
- // decodeTypeOrValue calls decoder.decodeType is decoder is a typeDecoder. Otherwise, it allocates a new element of
187
- // type t and calls decoder.DecodeValue on it.
184
+ // decodeTypeOrValue calls decoder.decodeType is decoder is a typeDecoder. Otherwise, it allocates a new element of type
185
+ // t and calls decoder.DecodeValue on it.
188
186
func decodeTypeOrValue (decoder ValueDecoder , dc DecodeContext , vr bsonrw.ValueReader , t reflect.Type ) (reflect.Value , error ) {
189
187
if typeDecoder , ok := decoder .(typeDecoder ); ok {
190
188
return typeDecoder .decodeType (dc , vr , t )
0 commit comments