| 1 |
// Copyright 2021 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
package a |
| 6 |
|
| 7 |
import ( |
| 8 |
"reflect" |
| 9 |
"sync" |
| 10 |
) |
| 11 |
|
| 12 |
type addressableValue struct{ reflect.Value } |
| 13 |
|
| 14 |
type arshalers[Options, Coder any] struct { |
| 15 |
fncVals []typedArshaler[Options, Coder] |
| 16 |
fncCache sync.Map // map[reflect.Type]unmarshaler |
| 17 |
} |
| 18 |
type typedArshaler[Options, Coder any] struct { |
| 19 |
typ reflect.Type |
| 20 |
fnc func(Options, *Coder, addressableValue) error |
| 21 |
} |
| 22 |
|
| 23 |
type UnmarshalOptions1 struct { |
| 24 |
// Unmarshalers is a list of type-specific unmarshalers to use. |
| 25 |
Unmarshalers *arshalers[UnmarshalOptions1, Decoder1] |
| 26 |
} |
| 27 |
|
| 28 |
type Decoder1 struct { |
| 29 |
} |
| 30 |
|
| 31 |
func (a *arshalers[Options, Coder]) lookup(fnc func(Options, *Coder, addressableValue) error, t reflect.Type) func(Options, *Coder, addressableValue) error { |
| 32 |
return fnc |
| 33 |
} |
| 34 |
|
| 35 |
func UnmarshalFuncV2[T any](fn func(UnmarshalOptions1, *Decoder1, T) error) *arshalers[UnmarshalOptions1, Decoder1] { |
| 36 |
return &arshalers[UnmarshalOptions1, Decoder1]{} |
| 37 |
} |